title: Internal Serve Error POST 500 AJAX, jQuery + PHP
body: <p>I've been trying to debug all day and I cannot get the internal error to disappear.</p>
  
  <p>The functionality of this code is that it will take in an email from the form and run it through the database to check if there is already an email in the database.</p>
  
  <p>If there is, it will display an error message vendor.js:9566 POST <a href="http://snacktally.com/emailcheck.php" rel="nofollow noreferrer">http://snacktally.com/emailcheck.php</a> 500 (Internal Server Error).</p>
  
  <p>Here's the jQuery:</p>
  
  <pre><code>$("#userform").submit(function(event) {
    var emailtext = {
      email: $("#Email").val();
    };
    $.ajax({
      type: "POST",
      url: "emailcheck.php",
      data: emailtext,
      dataType: 'json',
      success: function(response, textStatus, req) {
        if (response == '1') {
          //default action
        } else {
          $("#emailField").css("border-left", "2px solid #ff3333");
          $("#passField").css("border-left", "2px solid #FCFCFC");
          $("#passVerField").css("border-left", "2px solid #FCFCFC");
          $("h1").text("Email Taken").css("color", "#ff3333");
          event.preventDefault();
        }
      },
      error: function(xhr, ajaxOptions, thrownError) {
        console.log(xhr.status);
        console.log(xhr.responseText);
        console.log(thrownError);
      }
    });
  });
  </code></pre>
  
  <p>and here's the PHP</p>
  
  <pre><code>&lt;?php
  #sql_host, user pass and db defined up here
  $con = mysqli_connect($sql_host,$sql_user,$sql_pass,$sql_db);
  
  #obtains the email from the php file
  if(isset($_POST('email')))
  {
      $email = $_POST('email');
  
      #runs it through the database
      $emailver = "SELECT `Email` FROM `SnackTally`.`User` WHERE `Email` = 
      '$email'";
  
      if($select = mysqli_query($con, $emailver)){
          #output 0 = false, not a valid email
          if(mysqli_fetch_assoc($select) &gt; 0)
          {
              #$emailErr = "Email already exists";
              mysqli_free_result($select);
              mysqli_close($con);
              echo '0';
          }
          else
          {
              mysqli_free_result($select);
              mysqli_close($con);
              echo '1';
          }
      }
  }else{
      mysqli_close($con);
      echo '0';
  }
  ?&gt;
  </code></pre>