title: jQuery Validate Remote - Check if email already exists
body: <p>I have a bit of an issue getting jQuery Validation to check if an email address already exists in a mysql table. </p>
  
  <p>Every time I submit the form, it tells me the email already exists, even though I know it doesn't.</p>
  
  <p>Here's the code I have:</p>
  
  <p><strong>validation.js</strong></p>
  
  <pre><code>$(document).ready(function () {
  
      $('#signup').validate({ 
          errorLabelContainer: "#cs-error-note",
          wrapper: "li",
          rules: {
              email: {
                  required: true,
                  email: true,
                  remote: {
                      url: "check-username.php",
                      type: "post"
                  }
              }
          },
          messages: {
              email: {
                  required: "Please enter your email address.",
                  email: "Please enter a valid email address.",
                  remote: "Email already in use!"
              }
          },
          submitHandler: function(form) {
              form.submit();
          }
      });
  
  });
  </code></pre>
  
  <p><strong>check-username.php</strong></p>
  
  <pre><code>&lt;?php
      require('../../private_html/db_connection/connection.php');
  
      $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
      $query = $conn-&gt;prepare("SELECT * FROM 'user_accounts' WHERE email = '" . $_POST['email'] . "'");
      $query-&gt;execute();
  
      if( $query-&gt;rowCount() &gt; 0 ){
          echo 'true';
      }
      else{
          echo 'false';
      }
  ?&gt;
  </code></pre>
  
  <p>Your help is much appreciated!</p>