<?
$objConnect = mysql_connect("localhost","easyuser1","pass") or die(mysql_error());
$objDB = mysql_select_db("easyuser1");
$strSQL = "SELECT * FROM User WHERE IDnumber = '".$_POST["id_number"]."' ";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if($objResult)
{
$con=mysqli_connect("localhost","easyuser2","pass2","easyuser2");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$name = mysqli_real_escape_string($con, $_POST['name']);
$last_name = mysqli_real_escape_string($con, $_POST['last_name']);
$id_number = mysqli_real_escape_string($con, $_POST['id_number']);
$times = mysqli_real_escape_string($con, $_POST['times']);
$branch = mysqli_real_escape_string($con, $_POST['branch']);
$branch_address = mysqli_real_escape_string($con, $_POST['branch_address']);
$sql="INSERT INTO vtb (name, last_name, id_number, times, branch, branch_address)
VALUES ('$name', '$last_name', '$id_number', '$times', '$branch', '$branch_address')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
echo '<meta http-equiv="refresh" content="3;URL=success.php">';
echo "Your information has been recorded...";
}
else
{
echo '<meta http-equiv="refresh" content="3;URL=exists.php">';
echo "ID Number you entered is not in our database!";
}
?>
我有表easyuser1
,我有我的客户信息。我有一个表单,我的现有用户(来自easyuser1
)应该填写,但脚本应该检查:
填写表单脚本时,应检查IDnumber
表中记录的用户easyuser1
。如果此ID号不存在,脚本应回显“您输入的ID号不在我们的数据库中!”。此时它运作良好。
填写表格信息后,应存储在easyuser2
表中。如果用户将再次尝试填写此表单脚本,则应检查表idnumber
中是否存在easyuser2
。如果存在id号,则应回显:“您已填写表格”。所以这是我的问题。感谢。