mysql - PHP, Checking if an Email is already in database -


i having troubles php code. have going on here form gets sent file , enters database. not enter database if email in database in account. having troubles want print out "and account email created" when email in database , print out "account created" when inserts email database. wrong no matter email enter when creating new account, runs if statement if enter email new database. clear, database enter email if new email code automatically use if statement.

here code in php:

$fname=$_post['fname']; $lname=$_post['lname']; $email=$_post['email']; $password=$_post['password']; $state=$_post['state']; $zip=$_post['zip']; $address1=$_post['address1'];  print"<h3>"; print"<a href ='projecthome.php'>store home&nbsp;&nbsp;&nbsp;</a>"; print"<a href ='createaccount.php'>create account&nbsp;&nbsp;&nbsp;   </a>"; print"<a href ='login.php'>login&nbsp;&nbsp;&nbsp;</a>"; print"<a href='browsecategories.php'>browse categories&nbsp;&nbsp;&nbsp; </a>"; print"<a href='search.php'>search book&nbsp;&nbsp;&nbsp; </a>"; print"<a href='orders.php'>orders&nbsp;&nbsp;&nbsp; </a>"; print"<a href ='contactus.php'>contact us&nbsp;&nbsp;&nbsp;</a>"; print"<a href ='index.html'>home(index)&nbsp;&nbsp;&nbsp;</a>"; print"</h3>";   $query="insert customers(email,passwd,firstname,lastname,address1,zipcode,state) values ('$email','$password','$fname','$lname','$address1',$zip,'$state')"; mysql_query($query);  $query="select * customers email = '$email'"; $result=mysql_query($query); $numofrows=mysql_numrows($result); if($numofrows==1) {     print"an account email created..<a href ='createaccount.php'>please enter new account email.</a>";     print"<a href ='createaccount.php'></a>";  } else {     print"account created."; }   @mysql_close($connection); 

thank you!

move insert query else

$query="select * customers email = '$email'"; $result=mysql_query($query); $numofrows=mysql_num_rows($result); if($numofrows==1) { print"an account email created..<a href ='createaccount.php'>please enter new account email.</a>"; print"<a href ='createaccount.php'></a>";  } else { $query="insert customers(email,passwd,firstname,lastname,address1,zipcode,state) values ('$email','$password','$fname','$lname','$address1',$zip,'$state')"; mysql_query($query); print"account created."; } 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -