title: PHP POST not working but GET works
body: <p>I have been struggling with this weird issue for too long now.</p>
  
  <p>I have searched through all the so posts of the same issue and none of the solutions have helped.</p>
  
  <p>I have an HTML form that is using the post method to log a user in.
  The form resubmits to the same page and PHP then checks if the submit button has been clicked and will then execute the appropriate code.</p>
  
  <p>The problem is that my $_POST variable is empty, but if I use the GET method it works.</p>
  
  <p>When I <code>VAR_DUMP ( $_POST )</code> it returns <code>array(0) { }</code> proving that nothing is getting posted. 
  Using $_REQUEST does not work either. 
  All my form fields have a name attribute.
  I am using XAMPP to host the files and I access it through localhost in my browser <a href="http://localhost:8080/project/admin.php" rel="nofollow noreferrer">http://localhost:8080/project/admin.php</a></p>
  
  <p>I feel like I am missing something really simple but I can't figure it.</p>
  
  <p>Here is my code</p>
  
  <h2>admin.php</h2>
  
  <pre><code>&lt;?php
  $failed = false;
  
  VAR_DUMP ( $_POST );
  if (isset($_POST["loginBtn"]))
  {
      echo "&lt;br&gt;working";
      loginUser();
  }
  
  function loginUser()
  {
      include 'dbconfig.php';//makes connection to the database
  
      $user = $_POST['username'];
      $pass = $_POST['password'];
  
      $pass = hash("sha256", $pass);
      $sql = $conn-&gt;prepare("SELECT * FROM users WHERE username=? AND password =?");
      $sql-&gt;bind_param("ss", $user, $pass);
      $sql-&gt;execute();
      $result = $sql-&gt;get_result();
  
      if (mysqli_num_rows($result) &gt; 0)
      {
          echo "In match";
          session_start();
  
          while ($row = $result-&gt;fetch_assoc())
          {
              $id_v = $row["userID"];
          }
  
          $_SESSION['userId'] = $id_v;
          $_SESSION['sessionId'] = session_id();
  
          header('Location: newPost.php');
  
      }
      else
      {
          $failed = true;
      }
  }
  
  ?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;title&gt;Admin&lt;/title&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"&gt;
      &lt;link rel="shortcut icon" href="resources/images/favicon.png"&gt;
      &lt;link rel="stylesheet" href="css/style.css"&gt;
  &lt;/head
  
  &lt;body&gt;
  &lt;section class="grey-bg"&gt;
          &lt;div class="container"&gt;
              &lt;div class="title mb-50 center"&gt;
                  &lt;h2&gt;Admin Login.&lt;/h2&gt;
              &lt;/div&gt;
              &lt;div class="row"&gt;
                  &lt;div class="section-content"&gt;
                      &lt;form action="admin.php" method="POST" role="form" id="form_login" name="form_login" &gt;
                          &lt;div class="form-group"&gt;
                              &lt;label for="username"&gt;Username&lt;/label&gt;
                              &lt;input class="form-control" type="text" name="username" id="username"
                                     placeholder="Username"
                                     data-required&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                              &lt;label for="password"&gt;Password&lt;/label&gt;
                              &lt;input class="form-control" type="password" name="password" id="password"
                                     placeholder="Password"
                                     data-required&gt;
                          &lt;/div&gt;
                          &lt;div class="form-group"&gt;
                              &lt;input class="btn btn-color-out" type="submit" id="loginBtn" name="loginBtn" value="Login"&gt;
                          &lt;/div&gt;
  
                          &lt;?php
                              if($failed)
                              {
                                  echo "&lt;span id='errorMsg' style='color: red;'&gt;Username and password do not match&lt;/span&gt;&lt;br/&gt;&lt;br/&gt;";
                              }
                          ?&gt;
                      &lt;/form&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/section&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>