title: Checking if email address exists using AJAX and PHP
body: <p>After discussing this on SO Chat for hours, someone helped me get started and with a little additions by myself, the following JSFiddle was produced:</p>
  
  <p><a href="http://jsfiddle.net/aKENW/2/" rel="nofollow">http://jsfiddle.net/aKENW/2/</a></p>
  
  <p>I have created a test mysql database on another online server. I have also placed a validation file with the following php code in it:</p>
  
  <pre><code>&lt;?php
  $db = new PDO('mysql:host=localhost;dbname=...', '...', '...');
  $db-&gt;setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
  $emailInput = $_POST['signUpemail'];
  $result = $db-&gt;prepare('SELECT * FROM people WHERE email=?');
  $result-&gt;execute(array($emailInput));
  $count = count($result-&gt;fetchAll());
  if ($count &gt; 0){
      echo 0;
  }
  else {
      echo 1;
  }
  ?&gt;
  </code></pre>
  
  <p>The above file is called <code>validation.php</code> and is placed on that same server. This file is accessed by the <code>url</code> parameter in the JSFiddle AJAX code.</p>
  
  <p>I have added <code>action="google.com"</code> in the form declaration with the intent that the user is redirected to that url if the username entered is valid and the email entered is valid after being checked against my database.</p>
  
  <p>The test email that already exists in the database is <code>test7@gmail.com</code>.</p>
  
  <p>What am I doing wrong?</p>
  
  <p><strong>EDIT:</strong> Sorry, I didn't make clear what the problem was in the original post. The problem is that the email is not validating at all. No matter what email address I put in the textbox, regardless of whether its in the database or not, it doesn't go through. The page is not being redirected to google.com. The only reason I added google.com is to make it obvious whether the form is actually working or not.</p>