title: After submitting a login form, URL remains on the action php
body: <p>Hi there I am currently working on a user login where there can be 2 different situations when a person submits the form. </p>
  
  <p>What I am trying to accomplish is that if someone logs in, 
  they would either be redirected to the user page or the admin page depending on what table their username is located.</p>
  
  <p>My problem is, after submitting the form, the browser shows a blank page with no errors, with the URL being the php action of the form.</p>
  
  <p>Here is my html file</p>
  
  <pre><code>&lt;?php
  //Start session
  //error_reporting = E_ALL &amp; ~E_NOTICE;
  ini_set( 'error_reporting', E_ALL &amp; ~E_NOTICE);
  session_start();
  
  //Unset the variables stored in session
  unset($_SESSION['SESS_MEMBER_ID']);
  unset($_SESSION['SESS_USERNAME']);
  unset($_SESSION['SESS_PASSWORD']);
  ?&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;link rel="stylesheet" href="css/style.css" title="" /&gt;
  &lt;link rel="stylesheet" href="css/animate.css" title="" /&gt;
  &lt;link href='http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,300' rel='stylesheet' type='text/css'&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.js"&gt;            &lt;/script&gt;
  &lt;script src="js/mouseEvents.js"&gt;&lt;/script&gt;
  &lt;title&gt;Grey Avenue Item Inventory Login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="container"&gt;
  
  &lt;div id="mainform" &gt;
      &lt;div id="formcontainer" class="animated fadeInDown"&gt;
          &lt;div id="formheader"&gt;
          &lt;div class="logocont"&gt;
              &lt;a href="#"&gt;&lt;span class="logoImg"&gt;&lt;/span&gt;&lt;/a&gt;
              &lt;h2 class="textheader"&gt;Inventory System Log-In&lt;/h2&gt;
          &lt;/div&gt;
  
          &lt;/div&gt;
      &lt;form action="login.php" method="post" id="loginform"&gt;
  
      &lt;div class="inputbox"&gt;  &lt;input type="text" name="username" placeholder="Username" maxlength="12"/&gt;&lt;/div&gt;
      &lt;div class="inputbox"&gt; &lt;input type="password" name="password" placeholder="Password"  maxlength="12"/&gt;&lt;/div&gt;
      &lt;/form&gt;
      &lt;div id="loginbutton"&gt;
              &lt;button type="submit" form="loginform" class="loginbutton" value="Log In"&gt;
              &lt;span class="loginbut_text"&gt;Log In&lt;/span&gt;
              &lt;/button&gt;
              &lt;button class="regbutton" value="Register"&gt;
              &lt;span class="loginbut_text"&gt;Register&lt;/span&gt;
              &lt;/button&gt;
          &lt;/div&gt;  
  
          &lt;div id="errormsg"&gt;
  &lt;?php
  if( isset($_SESSION['ERRMSG_ARR']) &amp;&amp; is_array($_SESSION['ERRMSG_ARR']) &amp;&amp;     count($_SESSION['ERRMSG_ARR']) &gt;0 ) {
  echo '&lt;ul class="err"&gt;';
  foreach($_SESSION['ERRMSG_ARR'] as $msg) {
  echo '&lt;li&gt;',$msg,'&lt;/li&gt;';
  }
  echo '&lt;/ul&gt;';
  unset($_SESSION['ERRMSG_ARR']);
  }
  ?&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And my login.php file</p>
  
  <pre><code>&lt;?php
  
  session_start();
  
  require("connect.php");
  require("lib/password.php");
  
  //Array to store validation errors
  $errmsg_arr = array();
  
  //Validation error flag
  $errflag = false;
  
  
  $username = $_POST["username"];
  $password = $_POST["password"];
  
  //Input Validations
  if($username == "") {
      $errmsg_arr[] = "*Username missing";
      $errflag = true;
  }
  if($password == "") {
      $errmsg_arr[] = "*Password missing";
      $errflag = true;
  }
  
  //If there are input validations, redirect back to the login form
  if($errflag) {
      $_SESSION["ERRMSG_ARR"] = $errmsg_arr;
      session_write_close();
      header("location: index.php");
      die();
  }
  
  if ($sql = $conn-&gt;prepare("SELECT id, username, password, firstName, lastName FROM users WHERE username = ?")){
  
      $sql-&gt;bind_param("s", $username) ;
      $sql-&gt;execute();
      $sql-&gt;store_result();
      $result = $sql-&gt;num_rows;
      $sql-&gt;bind_result($id, $username, $passwordhash, $firstName, $lastName);
      $sql-&gt;fetch();
  
      if ($result &gt; 0){
          if(password_verify($password, $passwordhash)){
              session_regenerate_id();
              $_SESSION["SESS_MEMBER_ID"] = $id;
              $_SESSION["SESS_USERNAME"] = $username;
              $_SESSION["SESS_PASSWORD"] = $password;
              $_SESSION["SESS_FIRSTNAME"] = $firstName;
              $_SESSION["SESS_LASTNAME"] = $lastName;
  
              session_write_close();
  
              header("location: inventory.php");
              die();  
          }
          else {
              //Login failed
              $errmsg_arr[] = "Username and Password do not match";
              $errflag = true;
              if($errflag) {
                  $_SESSION["ERRMSG_ARR"] = $errmsg_arr;
                  session_write_close();
                  header("location:index.php");
                  die();
              }
          }
      }
  }
  else {
      if($sql = $conn-&gt;prepare("SELECT id, username, password, firstName, lastName     FROM admin WHERE username=?")){
          $sql-&gt;bind_param("s", $username);
          $sql-&gt;execute();
          $sql-&gt;store_result();
          $result = $sql-&gt;num_rows;
  
          $sql-&gt;bind_result($id, $username, $passwordhash, $firstName, $lastName);
          $sql-&gt;fetch();
  
          if($result &gt; 0){
              if(password_verify($password, $passwordhash)){
                  session_regenerate_id();
                  $_SESSION["SESS_MEMBER_ID"] = $id;
                  $_SESSION["SESS_USERNAME"] = $username;
                  $_SESSION["SESS_PASSWORD"] = $password;
                  $_SESSION["SESS_FIRSTNAME"] = $firstName;
                  $_SESSION["SESS_LASTNAME"] = $lastName;
  
                  session_write_close();
  
                  header("location:  http://www.greyavenue.ph/shoplogin/inventoryadmin.php");
                  die();  
              }
              else {
                  //Login failed
                  $errmsg_arr[] = "Username and Password do not match";
                  $errflag = true;
                  if($errflag) {
                      $_SESSION["ERRMSG_ARR"] = $errmsg_arr;
                      session_write_close();
                      header("location: index.php");
                      die();
                  }
              }
          }
          else{
              //Login failed
              $errmsg_arr[] = "Username and Password not found";
              $errflag = true;
              if($errflag) {
                  $_SESSION["ERRMSG_ARR"] = $errmsg_arr;
                  session_write_close();
                  header("location: http://www.greyavenue.ph/shoplogin/index.php");
                  die();
              }
          }
      }
  }
  ?&gt;
  </code></pre>
  
  <p>I am confused because the login seems to function and redirect the browser to the pages when I am not hashing the password before, but now after changing the code with the hash function the URL remains at this php file.</p>
  
  <p>Really appreciate the effort in taking the time to read and answer my question in advance! Thanks!</p>