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. Link to comment https://forums.phpfreaks.com/topic/111043-check-for-duplicate-entries/ 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. Link to comment https://forums.phpfreaks.com/topic/111043-check-for-duplicate-entries/#findComment-569826 Share on other sites More sharing options...
Imad Posted June 20, 2008 Author Share Posted June 20, 2008 Thanks, it worked. Link to comment https://forums.phpfreaks.com/topic/111043-check-for-duplicate-entries/#findComment-569841 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.