Hi the code I have below works exactly the way I want it to. Im sure there is a way to simplify the if else statements, eliminating the { echo ""; } part. Any suggestions? Thanks. $sql = "SELECT user_id FROM users WHERE email='$email'"; $resulte = mysql_query($sql) or die("Couldn't execute QUERY."); $nume = mysql_num_rows($resulte); if(mysql_num_rows($resulte)==0) { echo ""; } else { $mess = "The email you entered is not available."; include("new_register.php"); exit(); } \$sql = "SELECT user_id FROM users WHERE user='$user'"; $resultu = mysql_query($sql) or die("Couldn't execute QUERY."); $numu = mysql_num_rows($resultu); if(mysql_num_rows($resultu)==0) { echo ""; } else { $mess = "The Username you entered is not available, please try again."; include("new_register.php"); exit(); } $sql = "SELECT user_id FROM users WHERE pass1=SHA('$pass1')"; $resultp = mysql_query($sql) or die("Couldn't execute QUERY."); $nump = mysql_num_rows($resultp); if(mysql_num_rows($resultp)==0) { $active=md5(uniqid(rand(), true));
There is conditional statements known as ternary or whatever in php. echo $a == $b ? "true" : "false"; If a is equal to b, it will print true, otherwise it will print false. IF it is if, elseif, elseif, else etc.. You will use a switch.
Instead of: if(mysql_num_rows($resultu)==0) { echo ""; } else { $mess = "The Username you entered is not available, please try again."; include("new_register.php"); exit(); } PHP: Use: if(mysql_num_rows($resultu) > 0) { $mess = "The Username you entered is not available, please try again."; include("new_register.php"); exit(); } PHP:
your code doesnt make any sense. Youre asking for a result to be returned from the database for email in the users table...and if 0 results come back (meaning theres no email that they just entered) your script is echoing " " (nothing.. Then your else statement says -- otherwise if some result DOES come back .. tell them that they entered the wrong email or that it doesnt exist. This doesnt make any sense to me at all the way you have it set up. Usually if result == 0 That means there's NO email in the database so then echo "No such email exists" ELSE = take them to the page or echo a logged in = "Hi ($username), welcome back to the website" blah blah. Your snippet leaves no way for somebody to successfully even log in etc.
Thanks Shownsyou, That's what I needed. to: ezprint I am still new to php. That is why I asked for help. I don't appreciate the way you have responded.
ezprint -- It's not a login script - the script checks to make sure an email address and username are unique when someone tries to register.