我希望在用户提交表单后显示带有欢迎消息的引用ID。
我的表格如下。
<form action="add_customers.php" method="post" onsubmit="MM_validateForm('name','','R','Telephone','','RisNum','E_mail','','RisEmail','pas sport_no','','R','remarks','','R');return document.MM_returnValue">
<tr>
<td> </td>
<td><label for="id"></label>
<input name="id" id="id" type="hidden"/></td>
</tr>
<tr>
<td>Name of the Applicant:</td>
<td><label for="name"></label>
<input type="text" name="name" id="name" /></td>
</tr>
<tr>
<td>Telephone</td>
<td><label for="Telephone"></label>
<input type="text" name="Telephone" id="Telephone" /></td>
</tr>
<tr>
<td>E-mail</td>
<td><label for="E_mail"></label>
<input type="text" name="E_mail" id="E_mail" /></td>
</tr>
<tr>
<td>Country applying for :</td>
<td><label for="country"></label>
<select name="country" id="country">
<option>Afghanistan</option>
<option>Africa</option>
<option>Zimbabwe </option>
</select></td>
</tr>
<tr>
<td>Visa Categeory:</td>
<td><label style="margin-left:0px" for="visa_categeory"></label>
<select name="visa_categeory" id="visa_categeory" onChange="visacatOnchange();">
<option>Visit</option>
<option>Business</option>
<option>Other</option>
</select><br />
<input type="text" name="other_category" id="other_category" value="" style="display:none;">
<script type="text/javascript">
function visacatOnchange(){
var visa_cat = document.getElementById('visa_categeory').value
if(visa_cat == "Other")
document.getElementById("other_category").style.display="block";
else
document.getElementById("other_category").style.display="none";
}
</script>
</td>
</tr>
<tr>
<td>Passport No:</td>
<td><input type="text" name="passport_no" id="passport_no" /></td>
</tr>
<tr>
<td>Remarks:</td>
<td><label for="remarks"></label>
<textarea name="remarks" id="remarks" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Submit" /></td>
</tr>
</form>
add_customers.php
<?
if( $_POST )
{
$con = mysql_connect("esource","Solutions","Solutions@1");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("Solutions", $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'];
$query = "
INSERT INTO `VKSolutions`.`customer_details` (
`id`,
`name`,
`Telephone`,
`E_mail`,
`country`,
`visa_categeory`, `other_category`, `passport_no`, `remarks`
)
VALUES ('$users_id', '$users_name', '$users_Telephone', '$users_E_mail',
'$users_country', '$users_visa_categeory', '$users_other_category', '$users_passport_no', '$users_remarks'
);";
mysql_query($query);
printf("<p>Your Reference id is %d\n (Please note this reference id for future)<p>", mysql_insert_id());
echo "<link rel='stylesheet' type='text/css' href='add_customers.css' />";
echo("<table>
<tr>
<td>Ref.ID</td>
<td>Name of the Applicant</td>
<td>Telephone</td>
<td>Country Applying for</td>
<td>Your Visa Category</td>
<td>Other Category</td>
<td>Your Passport Number</td>
<td>Your Remark</td>
</tr>
</table>
");
mysql_close($con);
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome ! Your Submitted details.</title>
</head>
<body>
<table style="
">
<tr>
<td><?php echo $_POST["name"]; ?></td>
<td><?php echo $_POST["Telephone"]; ?> </td>
<td><?php echo $_POST["E_mail"]; ?></td>
<td><?php echo $_POST["country"]; ?> </td>
<td><?php echo $_POST["visa_categeory"]; ?></td>
<td><?php echo $_POST["other_category"]; ?> </td>
<td><?php echo $_POST["passport_no"]; ?></td>
<td><?php echo $_POST["remarks"]; ?> </td>
</tr>
</table>
</body>
</html>
现在我的问题是每当用户将数据提交到mysql中,然后自动显示带有id号的详细信息。一切看起来都不错,但它没有显示id。
感谢。
答案 0 :(得分:0)
在提交按钮上,您可以选择最后一个ID并显示
using select max(id) from tbl;