Jump to content

[SOLVED] php/mysql checking for duplicates in database


laron

Recommended Posts

If checking if a new user has the same name as an old user, something like this is enough:

 

$sql = "SELECT * FROM users WHERE username = '$new_user'";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
  print "$new_user already exists!\n";
} else {
  print "$new_user really is new!\n";
}

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.