I have a MySQL database and form in php.
I have successfully updated into MySQL database when a user submit his details.
Now i have a question.
I have 5 forms with same fields in the same web page. Now a user submit all 5 forms and click submit button, then save that details into MySQL database.
I know the code if a user submit single form how to save into database. But i need submit multiple forms with the same fields how to save in database.
My code is looking like this if a user submit single form.
<?
if( $_POST )
{
$con = mysql_connect("xx","xx","xx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("xx", $con);
$users_id = $_POST['id'];
$users_name = $_POST['name'];
$users_Telephone = $_POST['Telephone'];
$users_E_mail = $_POST['E_mail'];
$users_country = $_POST['country'];
$users_visa_categeory = $_POST['visa_categeory'];
$users_other_category = $_POST['other_category'];
$users_passport_no = $_POST['passport_no'];
$users_remarks = $_POST['remarks'];
$users_date = $_POST['date'];
$query = "
INSERT INTO `xx`.`xx` (
`id`,
`name`,
`Telephone`,
`E_mail`,
`country`,
`visa_categeory`, `other_category`, `passport_no`, `remarks`, `date`
)
VALUES ('$users_id', '$users_name', '$users_Telephone', '$users_E_mail',
'$users_country', '$users_visa_categeory', '$users_other_category', '$users_passport_no', '$users_remarks', '$users_date'
);";
mysql_query($query);
echo"<br /><br />";
echo" &n bsp; ";
printf(" <p> &nbs p;
& nbsp;
Your Reference id is %d\n (Please note this reference id for future)<p>", mysql_insert_id());
mysql_close($con);
}
?>
<table style="
background-color:#999;
color:#000;
text-align: left; width:500px; margin-left:250px; margin-top:20px;" border="1">
<tr>
<td style="color:#fff; text-indent:10px">Your Name:</td>
<td style="color:#00F; text-indent:10px"><?php echo $_POST["name"]; ?></td>
</tr>
<tr> <td style="color:#fff; text-indent:10px">Telephone:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["Telephone"]; ?> </td>
<tr> <td style="color:#fff; text-indent:10px">E_mail:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["E_mail"]; ?></td> </tr>
<tr> <td style="color:#fff; text-indent:10px">Country:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["country"]; ?> </td> </tr>
<tr> <td style="color:#fff; text-indent:10px">Visa_Categeory:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["visa_categeory"]; ?></td> </tr>
<tr> <td style="color:#fff; text-indent:10px">Other_Category:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["other_category"]; ?> </td> </tr>
<tr> <td style="color:#fff; text-indent:10px">Passport_No:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["passport_no"]; ?></td> </tr>
<tr> <td style="color:#fff; text-indent:10px" valign="top">Remarks:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["remarks"]; ?> </td> </tr>
<tr> <td style="color:#fff; text-indent:10px" valign="top">Date:</td><td style="color:#00F; text-indent:10px"><?php echo $_POST["date"]; ?> </td> </tr>
</tr>
</table>