Having trouble getting the section labelled "check for
duplicate entry of username" ... the script works but does not
appear to check for a duplicate username as it accepts further
entries using the same username... has anybody got any ideas
where I am going wrong here
Mel
<?
if ((!$name) || (!$email_adr) || (!$web_adr) || (!$username) || (!$password) || (!$our_link)) {
header("Location: http://localhost/new_register.html");
exit;
}
$db_name = "testDB";
$table_name = "register";
$connection = @mysql_connect("localhost", "sandman", "tQ9472b")
or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection)
or die("Couldn't select database.");
//Check for duplicate entry of username
$sql="SELECT * FROM $table_name WHERE username='$username'";
$result = mysql_query($sql) or die("Couldn't execute query.");
$num_rows=mysql_num_rows($result);
if($username>=1):
print "This username is already in use. Please, return and choose another";
exit;
endif;
// End of duplicate check section
// This section inserts form info into table - and is working fine
$sql = "INSERT INTO $table_name
(id, name, email_adr, web_adr, username, password, our_link)
VALUES
(\"\", \"$name\", \"$email_adr\",\"$web_adr\", \"$username\", password(\"$password\"),\"$our_link\")
";
$result = @($sql,$connection) or die("Couldn't execute query.");
?>