else statements not working
Posted: Tue Sep 30, 2003 9:48 am
The following code should check a username against a database, then check an email address, and if both ok, add the info to the database, but if either of the details are wrong it shows the wrong username message. Help? Cheers -Linkjames
Code: Select all
$namecheck = @mysql_query("SELECT username FROM users WHERE username LIKE '$username'");
if (mysql_num_rows($namecheck) != 0) {
echo 'Sorry username taken';
}
else {
$emailcheck = @mysql_query("SELECT email FROM users WHERE email LIKE '$email'");
if (mysql_num_rows($emailcheck) != 0) {
echo 'Sorry email taken';
}
else {
$result = @mysql_query("INSERT INTO users (username, password, email, verifycode, verifyed ) VALUES ('$username','$passworddata','$email','$verifycode','$verifyed')");
// End email check else
}
// End username check else
}