I am trying to make sure that the username that the user is trying to sign up with is not already talken. But no matter if the user is there or not. I always get the
echo "That user already exists!";
As far as I can tell this code is right. I have been over it a 100 times. Can anyone see anything out of place.
Thanks.
Code below:
<?
if ((!$email) || (!$pass)) {
echo "complete the form.";
exit;
}
$db_name = "xxxxxx";
$table_name = "users";
$connection = @mysql_connect("localhost", "xxxxxxx", "xxxxxx")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
$sql = "SELECT * FROM $table_name
WHERE email = '$emai' AND pass = '$pass'";
$result = mysql_query($sql)
or die ("Can't execute query.");
$num = mysql_numrows($result);
if ($num != 0) {
echo "username and pass are good!";
} else {
echo "That user already exists!";
exit;
}
?>