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:

  1. while filling form script should check idnumber of user recorded in easyuser1 table. if such id number not exist script should echo "id number entered not in our database!". @ moment works well.

  2. after filling form information should stored in easyuser2 table. if user try again filling form script should check if idnumber exists in table easyuser2. if id number exists should echo: "you have filled form". here problem. thanks.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -