Click here to Skip to main content
15,041,025 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Okay, so I've got a PHP script that I made that should check to see if a username/email is signed up (This is on a signup page). It stops the MySQL entry from being made, but still runs the final else, even if one of the if/elseif's run.


PHP
    $checka = mysqli_query($con,"SELECT id FROM user WHERE user='$user'");

$checkb = mysqli_query($con,"SELECT id FROM user WHERE email='$email'");

$checkc = mysqli_query($con,"SELECT id FROM user WHERE ppage='$string'");


  if (mysql_num_rows($checka) >= 1){

echo 'That username is already in use!';

mysqli_close($con);

}

  elseif (mysql_num_rows($checkb) >= 1){

echo 'That email is already in use!';

mysqli_close($con);

}

  elseif (mysql_num_rows($checkc) >= 1){

echo 'An error occured, please try again!';

mysqli_close($con);


} else {

//This still runs
Posted
Comments
Legor 16-May-14 7:44am
   
Why didnt you show the else path as well? How did you make sure that your else path gets executed each time?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900