daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest May 31st, 2017 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Authentication Check
  3. if(!isset($_SESSION['user']['is_logged_in'] || $_SESSION['user']['is_logged_in'] !== true) )
  4. {
  5.     if( isset($_POST['username']) && isset($_POST['password']) )
  6.     {
  7.         // Query database for valid user details
  8.         $dbh->query("SELECT password FROM users WHERE username='{$_POST['username']}' LIMIT 1");
  9.  
  10.         $password = $dbh->fetch(PDO::FETCH_ASSOC);
  11.  
  12.         // Verify user password is valid
  13.         if( $password['password'] !== sha1($_POST['password']) )
  14.         {
  15.             // User validation fails
  16.         }
  17.         else
  18.         {
  19.             // Set user session data
  20.             $_SESSION['user']['is_logged_in'] = true;
  21.             $_SESSION['user']['username'] = $_POST['username'];
  22.         }
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top