boblan66 Posted December 28, 2010 Share Posted December 28, 2010 I would like to know if I'm thinking in the right direction? I recently was looking at sample code that gave this as an example: $sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'"); $sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'"); If I learned correctly while reading about SQL, the two lines of code could have been one. Such as: $sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address' AND username='$username'"); Is this correct? Quote Link to comment https://forums.phpfreaks.com/topic/222844-sql-statement-question/ Share on other sites More sharing options...
Maq Posted December 28, 2010 Share Posted December 28, 2010 Sure, but what exactly are you trying to do? Quote Link to comment https://forums.phpfreaks.com/topic/222844-sql-statement-question/#findComment-1152317 Share on other sites More sharing options...
boblan66 Posted December 28, 2010 Author Share Posted December 28, 2010 I am creating a membership site for my wife's high school class. This code was part of an example for checking if the username and password was valid. Quote Link to comment https://forums.phpfreaks.com/topic/222844-sql-statement-question/#findComment-1152323 Share on other sites More sharing options...
Maq Posted December 28, 2010 Share Posted December 28, 2010 I am creating a membership site for my wife's high school class. This code was part of an example for checking if the username and password was valid. The validity of usernames, emails, and passwords should be checked server-side (PHP). You also may want to use an OR rather than an AND because you would want to check if either the email or username already exists. Quote Link to comment https://forums.phpfreaks.com/topic/222844-sql-statement-question/#findComment-1152326 Share on other sites More sharing options...
boblan66 Posted December 28, 2010 Author Share Posted December 28, 2010 Thank you for your quick response. You validified my thinking. Quote Link to comment https://forums.phpfreaks.com/topic/222844-sql-statement-question/#findComment-1152330 Share on other sites More sharing options...
Maq Posted December 28, 2010 Share Posted December 28, 2010 Thank you for your quick response. You validified my thinking. No problem. If you have questions regarding validation be sure to start a new thread. Quote Link to comment https://forums.phpfreaks.com/topic/222844-sql-statement-question/#findComment-1152333 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.