title: create login for user and admin
body: <p>I have managed to create login for user but trying to implement an admin login now any help would be appreciated, so far i have:</p>
  
  <pre><code>        $query = "
          SELECT
              id,
              username,
              password,
              salt,
              email,
      firstname,
      admin
          FROM users
          WHERE
              username = :username 
      ";
  
  
      $query_params = array(
          ':username' =&gt; $_POST['username']
      );
  
      try
      {
  
          $stmt = $db-&gt;prepare($query);
          $result = $stmt-&gt;execute($query_params);
  
      }
      catch(PDOException $ex)
      {
      $ex-&gt;getMessage().
  
          die("Failed to run query: " . $ex-&gt;getMessage());
      }
  
      $login_ok = false;
      $row = $stmt-&gt;fetch();
      if($row)
      {
  
          $check_password = hash('sha256', $_POST['password'] .  
          $row['salt']);
          for($round = 0; $round &lt; 65536; $round++)
          {
              $check_password = hash('sha256', $check_password .  
              $row['salt']);
          }
  
          if($check_password === $row['password'])
          {
  
              $login_ok = true;
          }
      }
  
  
  
      if($login_ok)
      {
          unset($row['salt']);
          unset($row['password']);
  
  
  
      $_SESSION['user'] = $row;
      $_SESSION['admin'] = $admin;
  
  
  
  
          header("Location: private.php");
          die("Redirecting to: private.php");
      }
  
      $admin = $row["admin"]==1;
  
      if($admin){
      header("Location: memberlist.php");
      }
  
      if(!$admin){
      header("Location: private.php");
      }
  
  
  
      else
      {
          // Tell the user they failed
          print("Login Failed.");
  </code></pre>
  
  <p>In my database i have set the admin field to boolean defualt value as 1.</p>