php - Check if username exists in one database -
<? $objconnect = mysql_connect("localhost","easyuser1","pass") or die(mysql_error()); $objdb = mysql_select_db("easyuser1"); $strsql = "select * user 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 connect 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 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 entered not in our database!"; } ?>
i have table easyuser1
have clients information. have 1 form existing user (from easyuser1
) should fill, script should check:
while filling form script should check
idnumber
of user recorded ineasyuser1
table. if such id number not exist script should echo "id number entered not in our database!". @ moment works well.after filling form information should stored in
easyuser2
table. if user try again filling form script should check ifidnumber
exists in tableeasyuser2
. if id number exists should echo: "you have filled form". here problem. thanks.
Comments
Post a Comment