title: Email not storing in variable from ajax request
body: <p>I'm attempting to use ajax to send input from an html form and try to fine the email in a MySQL database. I tested the search and it works just fine (using dummy data.) I have my PHP files running on WAMP. I checked Chrome to see if the email/password are showing and they are. 
  Here is my code: </p>
  
  <p>HTML &amp; Ajax
  
  </p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;!--initialize jquery from js folder--&gt;
          &lt;script src ="js/jquery-3.3.1.min.js"&gt;&lt;/script&gt;
  
      &lt;/head&gt;
      &lt;body&gt;
              &lt;!--output of the json--&gt;
              &lt;div&gt;
                      &lt;!--set the id to DOM to show output--&gt;
                      &lt;ul id="DOM"&gt;
  
                      &lt;/ul&gt;
              &lt;/div&gt;
              &lt;form&gt;
                  &lt;label&gt;&lt;b&gt;Email&lt;/b&gt;&lt;/label&gt;
                  &lt;input type="text" placeholder="Enter email" id="email" 
      required&gt;
                  &lt;br/&gt;
                  &lt;label&gt;&lt;b&gt;Password&lt;/b&gt;&lt;/label&gt;
                  &lt;input type="text" placeholder="Enter password" id="passwrd" 
      required&gt;
                  &lt;br/&gt;
                  &lt;button type="button" id="submit"&gt;Login&lt;/button&gt;
              &lt;/form&gt;
              &lt;a href="insert.html"&gt;insert&lt;/a&gt;
              &lt;a href="delete.html"&gt;delete&lt;/a&gt;
              &lt;a href="index.html"&gt;show data&lt;/a&gt;
              &lt;a href="login.html"&gt;login&lt;/a&gt;
  
                      &lt;!--Implementation of jquery/ajax--&gt;
          &lt;script type="text/javascript"&gt;
              $('#submit').on('click',function(e){
                  e.preventDefault()
                  var data = {
                      email: $("#email").val(),
                      passwrd: $("#passwrd").val()
                      }
                  $.ajax({
                      url : "http://localhost/api/login.php",
                      type : "POST",
                      dataType : "json",
                      data : JSON.stringify(data),
                      //on success it will call this function
                      success : function(data){
                          alert(data.toString());
                          //if fail it will give this error
                      }, error : function(e){
                          alert("failed to work:" +JSON.stringify(e));
                      }
                  });
              });
          &lt;/script&gt;
          &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  
  
  <p>PHP</p>
  
  <pre><code>include "db.php";
      header('Content-type: application/json');
      //$con-&gt;escape_string
      $email = isset($_POST['email']);
      //$email = "fk5829@wayne.edu";
      $result = $con-&gt;query("SELECT * FROM users WHERE email='$email'");
      echo "$email";
      if($result-&gt;num_rows == 0){ //if the user doesnt exist
          $_SESSION['message'] = "user doesnt exist";
          echo ' / user not exist / ';
      }   
      else{ //user exists
          $user = $result-&gt;fetch_assoc();
          if(password_verify(isset($_POST['passwrd']), $user['passwrd'])){ 
      //Verify the password entered
              //if password correct, link information from DB to session 
              //variables
              $_SESSION['f_name']= $user['f_name'];
              $_SESSION['l_name']= $user['l_name'];
              $_SESSION['email']= $user['email'];
              $_SESSION['authorized']= $user['authorized'];
  
              //Will be used to check if users session is logged 
              //in/allowed to do things
              $_SESSION['logged_in'] = true;
              //return to Success
              return $_SESSION['logged_in'];
              exit("Success");
          }
          else{
              $_SESSION['message'] = "You have entered the wrong password, 
      please try again";
          }
          echo ' / user exists / ';
      }
       echo ' / After the check / ';
  </code></pre>
  
  <p>My question is this: Why is the email from the form id "email" not getting stored in $email? is it on my ajax request side? or is it in my PHP file when im trying to $_POST?</p>
  
  <p>Any direction is appreciated.</p>