title: jQuery POST not executing php script
body: <p>I have the following jQuery in my index.php file (www root):</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
          $('#loginForm').submit(function() {
              var username = $("#username").val();
              var password = $("#password").val();
              $.post("php/login.php",
                  {
                      username: username,
                      password: password
                  },
                  
              function(data,status){
                  $("#loginstatus").html(data);
                  alert(data);
          }
                     
          );
              
          });
      });</code></pre>
  </div>
  </div>
  </p>
  
  <p>and the following php script in the folder php:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php
      $username = isset($_POST["username"]) ? $_POST["username"] : '' ;
      $password = isset($_POST["password"]) ? $_POST["password"] : '' ;
      $dbhost = "localhost";
      $dbuser = "s150314";
      $dbpass = "password";
      $dbname = "users";
      $loginerror = "";
      
      $conn = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
      
      $sqlu = "SELECT username FROM users WHERE username LIKE '$username' ";
      $sqlp = "SELECT password FROM users WHERE password LIKE '$password' ";
      $sqlfn = "SELECT FirstName,LastName FROM users WHERE username LIKE '$username' ";
      
      $resultu = mysqli_query($conn, $sqlu) ;
      $resultp = mysqli_query($conn, $sqlp) ;
      $resultfn = mysqli_query($conn, $sqlfn) ;
      
      if (mysqli_num_rows($resultu) &gt; 0 &amp;&amp; mysqli_num_rows($resultu) &gt; 0 ) {
          while($row = mysqli_fetch_assoc($resultfn)) {
              $_SESSION["FirstName"] = $row["FirstName"];
          }
          echo "Success!";
          header("Location: ../pages/redirect.php");
      } else {
          echo "Error!";
      }
      
  ?&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>However there is no change on the submission of the form. In theory I am supposed to be redirected to redirect.php... if I replace the php code back into index.php it works flawlessly.</p>