SHARE
TWEET

Untitled

a guest May 22nd, 2018 119 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <body>
  3. <?php
  4. session_start();
  5.  
  6.  
  7. $username = $_POST['username'];
  8. $password = $_POST['password'];
  9.  
  10.  
  11. $dbhost = 'localhost';
  12. $dbname = 'basiclogin';
  13. $dbuser = 'root';
  14. $dbpass = 'Password@1'; //not really
  15. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  16. mysql_select_db($dbname, $conn);
  17.  
  18. $username = mysql_real_escape_string($username);
  19. $query = "SELECT password, salt
  20.        FROM users
  21.        WHERE username = '$username';";
  22.  
  23. if (!mysql_query($query,$conn))
  24.   {
  25.   die('Error: ' . mysql_error());
  26.   }
  27.  
  28. $result = mysql_query($query);
  29. if(mysql_num_rows($result) < 1) //no such user exists
  30. {
  31.    
  32.     header('Location: login.php');
  33. }
  34. $userData = mysql_fetch_array($result, MYSQL_ASSOC);
  35. $hash = hash('sha256', $userData['salt'] . hash('sha256', $password) );
  36. if($hash != $userData['password']) //incorrect password
  37. {
  38.  
  39.     header('Location: login.php');
  40.  
  41. }
  42.  
  43. else
  44. {
  45. //Login Successful
  46.             session_regenerate_id();
  47.             $member = mysql_fetch_assoc($result);
  48.             $_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
  49.        
  50.             session_write_close();
  51.             header("location: welcome.php");
  52.                
  53.            
  54. }
  55. ?>
  56.  
  57.  
  58. </body>
  59. </html>
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