title: Validate email with database
body: <p>I have created a form and have validated everything using PHP, but can't figure out how to validate email from database. If I have the entered username in the database, I want it to display an error. I have connect.php and </p>
  
  <p>just for an example -</p>
  
  <p>here's how i validate password -</p>
  
  <pre><code>if(!empty($_POST['password']))
  {
   if($_POST['password'] != $_POST['cpass']) 
   {
    $errors[] = 'The password and confirm password do not match.';
   }
   else
   {
    $p=trim($_POST['password']);
   }
  }
  </code></pre>
  
  <p>here is what i'm trying to do -</p>
  
  <pre><code>$getusername = "SELECT username FROM users WHERE ($u,$username)";
  if($getusername)
  {
      echo 'Username is already in use.';
  }
  else
  {
      $g=trim($_POST['username']);
  </code></pre>
  
  <p>}</p>
  
  <p>THIS RESULTS IN A PARSE ERROR.</p>