title: Trouble with AJAX login call
body: <p>I'm trying to implement a simple login form with an AJAX call that redirects to a page where I query the database I have and then redirect the user to the index page or back to the login page.</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;form method="post"&gt;
  &lt;h4&gt; Please Login &lt;/h4&gt;
      &lt;input id="user" class="name" type="text" placeholder="Enter Username"/&gt;
      &lt;input id = "pass" class="pw" type="password" placeholder="Enter Password"/&gt;
      &lt;ul&gt;
          &lt;li&gt;&lt;a href="#"&gt;Forgot your password?&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href="#"&gt;Please Register Here&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
      &lt;input class="hvr-shrink" id="submitlogin" type="submit" value="Log in"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>jQuery/AJAX:</p>
  
  <pre><code>$("#submitlogin").click(function() {
      var $username = document.getElementById("user").value;
      var $pass = document.getElementById("pass").value;
      $.ajax ({
          url: "login_request.php",
          type: "POST",
          data: {
             'username' : $username,
             'password' : $pass
          }
      });
  });
  </code></pre>
  
  <p>login_request.php</p>
  
  <pre><code> include "connect.php";
   $myusername = mysqli_real_escape_string($db,$_POST['username']);
   $mypassword = mysqli_real_escape_string($db,$_POST['password']); 
  
  $sql = "SELECT username, password FROM `CGSB_Compliance`.`nd_users` WHERE username = '$myusername' AND password = '$mypassword'";
  $result = mysqli_query($db, $sql);
  $count = mysqli_num_rows($result);
  
  if($count == 1){
      $_SESSION['user'] = $myusername;
      header("location:index.php");
  } else {
      header("location:login.php");
  }
  </code></pre>
  
  <p>I have a table with one username and password, and every time I login, it just refreshes the login page. I checked my code a few times now and I can't seem to find the reason as to why it's not working. I have a feeling it's a silly mistake on my part but I looked at lots of examples and they all have pretty much the same thing. Any help is appreciated.</p>