title: Ajax php post not authenticating
body: <p>I have a sample script that will authenticate my users to access the page. My issue is when I post the values the js file does reflect that the data has been serialized but when it is posted to the php file to check if the database record exists the users still gets access to the page whether the login in details are correct or wrong. For some reason it seems not to take my `$_POST['pass'] and my $_POST['user_email'] values. But if I manually type in the user email and password in the php file to replace the variables it will works.</p>
  
  <p>HTML form</p>
  
  <pre><code>&lt;form class="login" id="login-form" name="login-form" method="post"&gt;
      &lt;p class="title"&gt;LOGIN&lt;/p&gt;
      &lt;input type="text" placeholder="Email" id="user_email" name="user_email" autofocus/&gt;
      &lt;i class="fa fa-user"&gt;&lt;/i&gt;
      &lt;input type="password" placeholder="Password" id="pass" name="pass" /&gt;
      &lt;i class="fa fa-key"&gt;&lt;/i&gt;
       &lt;button&gt;
        &lt;i class="spinner" style="outline:none;"&gt;&lt;/i&gt;
        &lt;span class="state"&gt;Log in&lt;/span&gt;
      &lt;/button&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>My js file to post the values. I added the console.log just to test see what values are been taken in by the script</p>
  
  <pre><code>$('document').ready(function()
  { 
      var working = false;
      $('.login').on('submit', function(e) {
          e.preventDefault();
          if(working)return
          working = true;
          var $this = $(this),
          $state = $this.find('button &gt; .state');
          $this.addClass('loading');
          $state.html('Authenticating');
  
          var data = $("#login-form").serialize();
          console.log(data);
  
          $.ajax({
  
              type : 'POST',
              url  : 'login_process.php',
              data : data,
              success :  function(response) {                     
                      console.log(response);
                      if(response=="ok"){
                          setTimeout(function() {
                              $this.addClass('ok');
                              $state.html('Welcome');
  
                              setTimeout(function() {
                                  $state.html('Log in');
                                  $this.removeClass('ok loading');
                                  working = false;
                              }, 4000);
  
                              setTimeout(function() {
                                  window.location.href = "/Home.aspx";
                              }, 4000);  
                          }, 3000);           
                          //$("#btn-login").html('&lt;img src="btn-ajax-loader.gif" /&gt; &amp;nbsp; Signing In ...');
                          //setTimeout(' window.location.href = "home.php"; ',4000);
                      } else {
                          console.log('ERROR IN LOGINING IN');    
                      }
                }
              });
              return false;
      });
  });
  </code></pre>
  
  <p>PHP file 'login_process'</p>
  
  <pre><code>&lt;?php
      session_start();
      require_once 'dbconfig.php';
      if(isset($_POST['pass']))
      {
          $user_email = urldecode(trim($_POST['user_email']));
          $user_password =trim($_POST['pass']);
          //$password = md5($user_password);
          $password = $user_password;
          try {   
  
              $stmt = $db_con-&gt;prepare("SELECT * FROM tbl_users WHERE user_email=:email");
              $stmt-&gt;execute(array(":email"=&gt;$user_email));
              $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
              $count = $stmt-&gt;rowCount();
  
              if($row['user_password']==$password){
                  echo "ok"; // log in
                  $_SESSION['user_session'] = $row['user_id'];
              }
              else{
                  echo "email or password does not exist."; // wrong details 
              }
          }
          catch(PDOException $e){
              echo $e-&gt;getMessage();
          }
  }
  ?&gt;
  </code></pre>