Hi,
I\'m new to php and I\'m having a problem checking if a username already exist in my database. I\'m using JS to validate the form and after that is all done I wish to check for existing usernames before going to the next page. Then just have a $msg say the name is taken.
here my code:
<?
if ($submit) {
$db_name = \"*******\";
$table_name = \"user_info\";
$connection = @mysql_connect(\"***\", \"***\", \"\") or die(\"Couldn\'t connect.\");
$db = @mysql_select_db($db_name, $connection) or die(\"Couldn\'t select database.\");
$sql = \"select username from user_info where username =\'$username\'\";
$result = @($sql,$connection) or die(\"Couldn\'t execute query 1.\");
if ($exists) {
$msg = \"that name alrealdy exists\";
}else {
exit;
}
}
?>
any help would be great.
Thanks,
Troy