Entry
How do I get PHP to check a MySQL dbase for a password and username to ensure that users cannot choose identical names and passwords
May 2nd, 2007 06:21
lorenzo campanis, Nick Oakley, Ben Udall,
You need to query for a username with
$res = mysql_query("select username from users
where username =
'".addslashes($_POST['username']). "'");
if(mysql_num_rows($res) > 0)
{
...you have a user
}
$_POST['username'] is the variable passed by your input box in your form.
addslashes will make sure you dont get an error in MySQL when O'Brien is
the username. visit php.net for more