Jump to content

[SOLVED] Stopping Repeats


Daleeburg

Recommended Posts

Of course, this is an easy thing to do. You just need to use a select query beforehand to find any match where a username is equal to the input username variable, like so:

 

require_once ('connect.php'); # Connect to the database

$query  = "SELECT * FROM users WHERE username='".$username."'";
$result = @mysql_query ($query);
$num = mysql_num_rows ($result); # How many results have that username

if ($num > 0) {
# The username is in use, so...send an error

}

} else {
# The username isnt in use, carry on

}

You'll probably need to change around the variable and field names, but that should work.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.