View Full Version : Making no repeat users.
Balkee867
07-21-06, 01:09 PM
I have a PHP script that allows a user to register, and all of his/her information is stored in a database. However, with the script that I have now, a user can register twice, using the same information, and the same info is stored twice in my database. How do I make it so that when a user submits the same information, they get an error message?
Here's an example.
$check = mysql_query("SELECT * FROM users WHERE username = '". mysql_real_escape_string($_POST['username']) ."'") OR die( mysql_error() );
if (mysql_num_rows($check) > 0)
{
echo 'Username already taken.';
}
else
{
// Insert new user.
}
EDIT:
And moving to database.
Balkee867
07-21-06, 02:16 PM
Great, thanks, that's exactly what I needed.
vBulletin® v3.6.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.