I need PHP script which does not register users who has same Username
<p>I need PHP script wich does not register users who has same Username. I write script, it work fine but it register users which have same USERNAME. I want that my script  Check Username  and if it Available continue registration and if it Unavailable Stop registration. I am sorry, my English is ill :d :D   PLZ write this script.</p>

<p>this is my script and plz tell how to edit this</p>

<p><a href="http://forums.digitalpoint.com/showthread.php?t=2468043#" rel="nofollow">my script </a></p>

<p>The script:</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;


&lt;body&gt;


&lt;?php require_once('Connections/tourname_regcs16.php'); ?&gt;
&lt;?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION &lt; 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }


  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);


  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}


$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}


if ((isset($_POST["MM_insert"])) &amp;&amp; ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO members (team_name, team_member1, team_member2, team_member3, team_member4, team_member5, email, phone_number, emoney, password,win ,defeat ,score , tour_status_complete, tour_status_progress, tour_status_willstart, team_status_payed, team_status_notpayed, team_place_1, team_place_2, team_place_3, team_place_4, team_place_5, team_place_6, team_place_7, team_place_8, team_place_9, team_place_10, team_place_11, team_place_12, team_place_13, team_place_14, team_place_15, team_place_16, team_place_17, team_place_18, team_place_19, team_place_20, team_place_final, `data`) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['team_name'], "text"),
                       GetSQLValueString($_POST['team_member1'], "text"),
                       GetSQLValueString($_POST['team_member2'], "text"),
                       GetSQLValueString($_POST['team_member3'], "text"),
                       GetSQLValueString($_POST['team_member4'], "text"),
                       GetSQLValueString($_POST['team_member5'], "text"),
                       GetSQLValueString($_POST['email'], "text"),
                       GetSQLValueString($_POST['phone_number'], "text"),
                       GetSQLValueString($_POST['emoney'], "text"),
                       GetSQLValueString($_POST['password'], "text"),
                       GetSQLValueString($_POST['win'], "text"),
                       GetSQLValueString($_POST['defeat'], "text"),
                       GetSQLValueString($_POST['score'], "text"),
                       GetSQLValueString($_POST['tour_status_complete'], "text"),
                       GetSQLValueString($_POST['tour_status_progress'], "text"),
                       GetSQLValueString($_POST['tour_status_willstart'], "text"),
                       GetSQLValueString($_POST['team_status_payed'], "text"),
                       GetSQLValueString($_POST['team_status_notpayed'], "text"),
                       GetSQLValueString($_POST['team_place_1'], "text"),
                       GetSQLValueString($_POST['team_place_2'], "text"),
                       GetSQLValueString($_POST['team_place_3'], "text"),
                       GetSQLValueString($_POST['team_place_4'], "text"),
                       GetSQLValueString($_POST['team_place_5'], "text"),
                       GetSQLValueString($_POST['team_place_6'], "text"),
                       GetSQLValueString($_POST['team_place_7'], "text"),
                       GetSQLValueString($_POST['team_place_8'], "text"),
                       GetSQLValueString($_POST['team_place_9'], "text"),
                       GetSQLValueString($_POST['team_place_10'], "text"),
                       GetSQLValueString($_POST['team_place_11'], "text"),
                       GetSQLValueString($_POST['team_place_12'], "text"),
                       GetSQLValueString($_POST['team_place_13'], "text"),
                       GetSQLValueString($_POST['team_place_14'], "text"),
                       GetSQLValueString($_POST['team_place_15'], "text"),
                       GetSQLValueString($_POST['team_place_16'], "text"),
                       GetSQLValueString($_POST['team_place_17'], "text"),
                       GetSQLValueString($_POST['team_place_18'], "text"),
                       GetSQLValueString($_POST['team_place_19'], "text"),
                       GetSQLValueString($_POST['team_place_20'], "text"),
                       GetSQLValueString($_POST['team_place_final'], "text"),
                       GetSQLValueString($_POST['data'], "date"));


  mysql_select_db($database_tourname_regcs16, $tourname_regcs16);
  $Result1 = mysql_query($insertSQL, $tourname_regcs16) or die(mysql_error());


  $insertGoTo = "cs16_reg_complete.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&amp;" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}








?&gt;
&lt;style type="text/css"&gt;
#form1 table tr td p {
    text-align: center;
}
&lt;/style&gt;




&lt;form action="&lt;?php echo $editFormAction; ?&gt;" method="post" name="form1" id="form1"&gt;
  &lt;table width="493" align="center"&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td width="120" align="right" nowrap="nowrap"&gt;გუნდის სახელი:&lt;/td&gt;
      &lt;td width="250"&gt;&lt;p&gt;&lt;input type="text" name="team_name" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;გუნდის წევრი №1:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="team_member1" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;გუნდის წევრი №2:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="team_member2" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;გუნდის წევრი №3:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="team_member3" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;გუნდის წევრი №4:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="team_member4" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;გუნდის წევრი №5:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="team_member5" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;Emoney:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="emoney" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;ელ. ფოსტა:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="email" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;მობ. ნომერი:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="text" name="phone_number" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;პაროლი:&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;input type="password" name="password" value="" size="32" /&gt;&lt;/p&gt;&lt;/td&gt;

    &lt;/tr&gt;
    &lt;tr valign="baseline"&gt;
      &lt;td nowrap="nowrap" align="right"&gt;&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;p&gt;&lt;br&gt;&lt;input type="submit" value="რეგისტრაცია" /&gt;&lt;/p&gt;&lt;/td&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;input type="hidden" name="win" value="0" /&gt;
  &lt;input type="hidden" name="defeat" value="0" /&gt;
  &lt;input type="hidden" name="score" value="0" /&gt;
  &lt;input type="hidden" name="tour_status_complete" value="Complete" /&gt;
  &lt;input type="hidden" name="tour_status_progress" value="In Progress" /&gt;
  &lt;input type="hidden" name="tour_status_willstart" value="Is Starting" /&gt;
  &lt;input type="hidden" name="team_status_payed" value="Payed" /&gt;
  &lt;input type="hidden" name="team_status_notpayed" value="Not Payed" /&gt;
  &lt;input type="hidden" name="team_place_1" value="Round I" /&gt;
  &lt;input type="hidden" name="team_place_2" value="Round II" /&gt;
  &lt;input type="hidden" name="team_place_3" value="Round III" /&gt;
  &lt;input type="hidden" name="team_place_4" value="Round IV" /&gt;
  &lt;input type="hidden" name="team_place_5" value="Round V" /&gt;
  &lt;input type="hidden" name="team_place_6" value="Round VI" /&gt;
  &lt;input type="hidden" name="team_place_7" value="Round VII" /&gt;
  &lt;input type="hidden" name="team_place_8" value="Round VIII" /&gt;
  &lt;input type="hidden" name="team_place_9" value="Round IX" /&gt;
  &lt;input type="hidden" name="team_place_10" value="Round X" /&gt;
  &lt;input type="hidden" name="team_place_11" value="Round XI" /&gt;
  &lt;input type="hidden" name="team_place_12" value="Round XII" /&gt;
  &lt;input type="hidden" name="team_place_13" value="Round XIII" /&gt;
  &lt;input type="hidden" name="team_place_14" value="Round XIV" /&gt;
  &lt;input type="hidden" name="team_place_15" value="Round XV" /&gt;
  &lt;input type="hidden" name="team_place_16" value="Round XVI" /&gt;
  &lt;input type="hidden" name="team_place_17" value="Round XVII" /&gt;
  &lt;input type="hidden" name="team_place_18" value="Round XVIII" /&gt;
  &lt;input type="hidden" name="team_place_19" value="Round XIX" /&gt;
  &lt;input type="hidden" name="team_place_20" value="Round XX" /&gt;
  &lt;input type="hidden" name="team_place_final" value="Final" /&gt;
  &lt;input type="hidden" name="data" value="&lt;?php 
echo "Server time: ".date("M d, Y - g:i:s A"); 
?&gt;" /&gt;
  &lt;input type="hidden" name="MM_insert" value="form1" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
