ok so here is your problem you added all these different actions to different forms so you are trying to send one piece of information to one page another to another page and so on, there is no way the database can collect it all, next you have to input fields both named Date_Returned when one should have been Date_Recieved.
This form really is a mess.
From what I gather by reading this you are making something that will record when a product is returned you need to save the following info:
issued by: User_Name
Date Issued: Date_Issued
Customer Name: Customer_Name
Product: Product_Name
Serial No: Serial_No
Date Recieved: Date_Recieved
Reason: Reason
Outcome: Outcome
Date Returned: Date_Returned
an easy way to do this is write everythign you need down on a piece of paper that you need as I did above on the left, then choose what you are going to name each field in the database as I did above on the right, now we need to create the correct database table because I do not think you did ;D
so lets create a new datebase table open up your database and run this sql:
[php]
CREATE TABLE productreturn
(
id
INT( 50 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
User_Name
VARCHAR( 50 ) NOT NULL ,
Date_Issued
VARCHAR( 25 ) NOT NULL ,
Customer_Name
VARCHAR( 50 ) NOT NULL ,
Product_Name
VARCHAR( 50 ) NOT NULL ,
Serial_No
VARCHAR( 50 ) NOT NULL ,
Date_Recieved
VARCHAR( 50 ) NOT NULL ,
Reason
TEXT NOT NULL ,
Outcome
TEXT NOT NULL ,
Date_Returned
VARCHAR( 50 ) NOT NULL ,
INDEX ( User_Name
, Customer_Name
)
) ENGINE = MYISAM ;
[/php]
now we are going to put EVERYTHING on the form page, there is no need for addition pages so create your productreturn.php I did not test this I just wrote it up really quick there is a better way to write out the striptags and escape string part but for now I think you should just see the basic way. so in product return add the following and let me know if everything works correctly!
[php]
<?php
$server="localhost";
$username="Username";
$password="Password";
$database="DB";
$connection = mysql_connect($server, $username, $password) or die('Could not connect'.mysql_error());
mysql_select_db($database, $connection) or die("Cannot select db.");
if($_POST['productreturn']=="welostmoney"){
$username=mysql_strip_tags($_POST['User_Name']);
$username=mysql_escape_string($username);
$dateissued=mysql_strip_tags($_POST['Date_Issued']);
$dateissued=mysql_escape_string($dateissued);
$customername=mysql_strip_tags($_POST['Customer_Name']);
$customername=mysql_escape_string($customername);
$productname=mysql_strip_tags($_POST['Product_Name']);
mysql_escape_string($productname);
$serialno=mysql_strip_tags($_POST['Serial_No']);
$serialno=mysql_escape_string($serialno);
$daterecieved=mysql_strip_tags($_POST['Date_Recieved']);
$daterecieved=mysql_escape_string($daterecieved);
$reason=mysql_strip_tags($_POST['Reason']);
$reason=mysql_escape_string($reason);
$outcome=mysql_strip_tags($_POST['Outcome']);
$outcome=mysql_escape_string($outcome);
$datereturned=mysql_strip_tags($_POST['Date_Returned']);
$datereturned=mysql_escape_string($datereturned);
mysql_query("INSERT INTO `productreturn` (`id`, `User_Name`, `Date_Issued`, `Customer_Name`, `Product_Name`, `Serial_No`, `Date_Recieved`, `Reason`, `Outcome`, `Date_Returned`) VALUES
(NULL, '$username', '$dateissued', '$customername', '$productname', '$serialno', '$daterecieved', '$reason', '$outcome', '$datereturned')");
$msg="Inserted Successfully!!!
";
}
?>
<? echo $msg; ?>
Issued By: |
<?php
$sql="SELECT User_ID, UserName FROM Users";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$User_ID=$row["User_ID"];
$UserName=$row["UserName"];
$options.="".$UserName;
}
?>
Choose
<?=$options?>
|
Date Issued:
|
|
Customer Name:
|
<?php
$sql="SELECT Customer_ID, CustomerName FROM Customer";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$Customer_ID=$row["Customer_ID"];
$CustomerName=$row["CustomerName"];
$options.="".$CustomerName;
}
?>
Choose
<?=$options?>
|
Product:
|
<?php
$sql=“SELECT Product_ID, Product_Name FROM RMAProduct”;
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$Product_ID=$row[“Product_ID”];
$Product_Name=$row[“Product_Name”];
$options.="<OPTION VALUE="$Product_ID">".$Product_Name;
}
?>
Choose
<?=$options?>
|
Serial No. |
|
Date Recieved:
|
|
Reason:
|
|
Outcome:
|
|
Date Returned:
|
|
|
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
|
[/php]