Imad Posted June 20, 2008 Share Posted June 20, 2008 Hi Guys, I need some help with searching for duplicate MySQL row entries. To be more specific, I have a table called users. I want to check to see if a username like the one someone wants to register as, is available or not; if so, I return an error. I did try searching in Google first but I couldn't find it. Thanks in advanced, Imad. Quote Link to comment Share on other sites More sharing options...
Stephen Posted June 20, 2008 Share Posted June 20, 2008 Do like $con=mysql_connect("host","user","pass"); mysql_select_db("db",$con); $one=mysql_query("SELECT * FROM users WHERE username='".$_POST["username"]."'"); $two=mysql_num_rows($one); if ($two!==0) { echo("Name taken."); } else { echo("Name avaliable."); } Assuming your form with the username is named "username" and its POST. Quote Link to comment Share on other sites More sharing options...
Imad Posted June 20, 2008 Author Share Posted June 20, 2008 Thanks, it worked. Quote Link to comment 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.