Guest User

Untitled

a guest
May 28th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. <html>
  2. <body>
  3.  <?php error_reporting(-1); ini_set('display_errors', 'on'); ?>
  4. <?php
  5. session_start();
  6.  
  7.            
  8. //Declare username and password variable from login form
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11.  
  12.  
  13. //NEW PDO WAY
  14. $conn = new PDO('mysql:host=localhost;dbname=basiclogin', 'root', 'Password@1');
  15.  
  16. //$result = mysql_query($query);
  17. $stmt = $conn->prepare("SELECT * FROM users WHERE username=?");
  18. $stmt->execute(array($username));
  19. $row_count = $stmt->rowCount();
  20. $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
  21.  
  22. //Number of rows < 1 than user not found
  23. if($row_count < 1)
  24. {
  25.  
  26. header('Location: index.php');
  27.  
  28. }
  29.  
  30. //$hash = hash('sha256', $results['salt'] . hash('sha256', $password) );
  31.  
  32. //if($hash != $query['password']) //incorrect password
  33. //{
  34.     //Return the user to the login page
  35.  //   header('Location: login.php');
  36.  
  37. //}
  38.  
  39. //else
  40. //{
  41. //Login Successful
  42.            
  43.                      
  44. //          $_SESSION['authlevel'] = $results['authlevel'];
  45.             $_SESSION['is_logged_in'] = true;
  46.             $_SESSION['member_name'] = $results['username'];
  47.             header("location: welcome.php");
  48.  
  49.  
  50.                
  51.            
  52. //}
  53.  
  54. ?>
  55.  
  56.  
  57. </body>
  58. </html>
Add Comment
Please, Sign In to add comment