am here coding a registration page but am kinda stuck i neeed an error that shows that the name is already taken.....i do have one but when u register it a name thats not already there it still says already exits here is my coding please help out
<?php include("utils.php"); include("tbc.php"); //include("functions.php"); echo "<link rel=\"StyleSheet\" type=\"text/css\" href=\"http://chillblock.wapdesire.com/nt4_us/teamblaze_css\" />"; echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>";echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
?>
<?php $login = $_POST["login"]; $pass = $_POST["pass"]; $email = $_POST["email"]; echo "<head>"; echo "<link rel=\"icon\" type=\"favicon_ico\" href=\"http://chillblock.wapdesire.com/nt4_us/img/teamblaze.ico\" />"; echo "<title>NT4.us - mobile wapsite creator/Mobile site builder</title>"; echo "</head>"; echo " "; if($_POST["login"] == '' || $_POST["pass"] == ''|| $_POST["email"] == '' ) { $error = "<img src=\"img/no.gif\" alt=\"\"/> Please Fill out all the fields"; } else if(strlen($_POST["login"]) < 4) { $error = "<img src=\"img/no.gif\" alt=\"\"/> Username - (sitename) must be 4 characters or more"; } else if(strlen($_POST["pass"]) <4) { $error = "<img src=\"img/no.gif\" alt=\"\"/> Password must be 4 characters or more"; } else if(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'. '@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $_POST['email'])) { $error = "<img src=\"img/no.gif\" alt=\"\"/> Please provide a valid email address"; } else if($_POST["login"]) { $error = "<img src=\"img/no.gif\" alt=\"\"/> Username - (sitename) is already taken, please try again"; }else{ mysql_query('INSERT INTO users (login, pass, email) VALUES ("' . addslashes($_POST['login']) . '", "' . md5($_POST['pass']) . '", "' . addslashes($_POST['email']) . '")'); $uid = mysql_insert_id(); echo "<img src=\"img/yes.gif\" alt=\"\"/> Site created successfully --- "; echo " "; echo "Site url: **$login$hostname** "; echo "Password: **$pass** "; echo "Email Address: **$email** --- "; echo "<a href=\"sitepanel.php\">Site Manager/Admin Control</a> "; echo " "; } echo "$error"; echo " "; ?>