SHARE
TWEET

Untitled

a guest Jun 29th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $username = isset ( $_POST [ 'lgnUsername' ] ) ? $_POST [ 'lgnUsername' ] : NULL;
  2. $password = isset ( $_POST [ 'lgnPassword' ] ) ? $_POST [ 'lgnPassword' ] : NULL;
  3.  
  4. try
  5. {
  6.     $query = $db -> prepare ( "SELECT COUNT(*) as uCount FROM users WHERE username = ? AND password = SHA256(?)" );
  7.     $query -> bindParam ( 1, $username, PDO :: PARAM_STR );
  8.     $query -> bindParam ( 2, $password, PDO :: PARAM_STR );
  9.     $query -> execute ( );
  10.    
  11.     // by this point, an exception would be thrown otherwise
  12.     // $row will contain an array
  13.     $row = $query -> fetch ( PDO :: FETCH_ASSOC );
  14.    
  15.     if ( $row [ 'uCount' ] == 0 )
  16.     {
  17.         // user does not exist
  18.     }
  19.     else
  20.     {
  21.         // user exists
  22.         $_SESSION [ 'hash' ] = md5 ( "test" );
  23.     }
  24. }
  25. catch ( PDOException $e )
  26. {
  27.     die ( $e -> getMessage ( ) );
  28. }
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