title: Php session, header, and password hash values
body: <p>i'm currently testing md5 not to store passwords in plain text.
  i'm working with 2 files, the first one registers users and inserts the md5 of the password in the database.
  The 2nd file is login.php where i attempt user login, comparing the hash value of the password typed with the hash value of the one that is stored,
  after testing that the 2 values are equal with echos, the header redirecting isn't working, here's my code for login.php if anyone can give me some tips : </p>
  
  <pre><code>    &lt;?php
  
     include("../config.php");
     session_start();
  
     if($_SERVER["REQUEST_METHOD"] == "POST") {
        // username and password sent from form 
  
        $myusername = mysqli_real_escape_string($db,$_POST['username']);
        $mypassword = mysqli_real_escape_string($db,$_POST['password']); 
  
   $sqlx = "SELECT passcode FROM jdashboard WHERE username = '".$myusername."'";
   $resultx = mysqli_query($db,$sqlx);
   $rowx = mysqli_fetch_array($resultx,MYSQLI_ASSOC);
   $storedpass=$rowx['passcode'];
  
  $enc_password = md5($mypassword);
  /*echo $enc_password;
  echo "&lt;br&gt;";
  echo $storedpass;*/
  /*
  $compare=strcmp($string1,$string2);
  */
  
        $sql = "SELECT id FROM jdashboard WHERE username = '$myusername' and passcode = '$mypassword'";
  
        $result = mysqli_query($db,$sql);
        $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
        $active = $row['active'];
  
        $count = mysqli_num_rows($result);
  
        // If result matched $myusername and $mypassword, table row must be 1 row
  
  
  
        if($count == 1) {
  $admin=0;
          //session_register("myusername");
          $_SESSION['myusername'] = 'myusername';
  $sql = "SELECT admin FROM jdashboard WHERE username = '".$myusername."'";
        $result = mysqli_query($db,$sql);
    $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  
  
  
  $admin= $row['admin'];
  
           $_SESSION['login_user'] = $myusername;
  
  
           if ($admin=='1'){
  
           header("location: welcome.php");
  
  
  
  
   }
  
   else if ($admin=='0' &amp;&amp; $storedpass == $enc_password){
  
  header("location: https://one.potentiallead.com/dshb/usr");
  
  
  
  
  }
        else {
           $error = "Your Login Name or Password is invalid";
        } }
     }
  ?&gt;
  </code></pre>
  
  <p>Thank you in advance !</p>