title: How to check for duplicate entry in DB?
body: <p>I've built a form on a site which captures a few fields including 'email' and posts it to a DB that I have with a table named 'data.' I'm using the jQuery Validate plugin to make sure all fields are complete, though I can't have duplicate email addresses in the db. </p>
  
  <p>The plugin came with a script named emails.php which it calls when verifying the field data and here's the code: </p>
  
  <pre><code>&lt;?php
  $request = trim(strtolower($_REQUEST['email']));
  $emails = array('steam@valve.com', 'bill@gates.com', 'blocked@email.com');
  $valid = 'true';
  foreach($emails as $email) {
  if( strtolower($email) == $request )
      $valid = '"Thats already taken."';
  }
  echo $valid;
  ?&gt;
  </code></pre>
  
  <p>This snippet is only checking the emails that are listed. Is there a way to query the DB to search through the table 'data' and check the 'emails' to see if there's a duplicate and hopefully post an error message if it is?</p>
  
  <p>Also, the script does seem to work when I use any of the example emails so it is essentially 'working' I just need to tweak it to check the DB.</p>