title: Check if username is taken
body: <p>i need to check if the username is taken and if it is it wont allow the user to register it will redirect them to the register page
   where should i add the script to check if the username is taken alredy? or where can i get a script for this
  heres my script what i have sofar.</p>
  
  <pre><code> &lt;?php
  
  // Check if he wants to register:
  if (!empty($_POST[username]))
  {
  // Check if passwords match.
  if ($_POST[password] != $_POST[password2])
      exit("Error - Passwords don't match. Please go back and try again.");
  
  // Assign some variables.
  $date = time (" d - m - Y ");
  $ip = $_SERVER[REMOTE_ADDR];
  
  require_once("connect.php");
  
  // Register him.
  $query = mysql_query("INSERT INTO members 
  (username, fname, email, password, date, ip)
  VALUES      ('$_POST[username]','$_POST[fname]','$_POST[email]','$_POST[password]','$date','$ip')")
  or die ("Error - Couldn't register user.");
  
  echo "Welcome $_POST[username]! You've been successfully reigstered!&lt;br /&gt;
      You Will Be Redirected To Our Home Page Where U Can Login ";
  exit();
  }
  
  ?&gt;
  </code></pre>