Guest User

Untitled

a guest
May 25th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2.  
  3. $username = $_POST['u'];
  4. $password = $_POST['p'];
  5.  
  6.  
  7. $host = 'localhost';
  8. $dbname = 'guestlist';
  9.  
  10. $DBH = new PDO("mysql:host=$host;dbname=$dbname", "root", "");
  11. $STH = $DBH -> prepare("SELECT * FROM users WHERE username=':user' and password=':pass';");
  12. $STH -> bindParam(':user', $username);
  13. $STH -> bindParam(':pass', $password);
  14. $rowCount = $STH -> execute();
  15.  
  16. if($rowCount == 1)
  17. {
  18.     start_session();
  19.     $_SESSION['username'] = $username;
  20.     return 1;
  21. }
  22. else
  23. {
  24.     return 0;  
  25. }
  26.  
  27.  
  28.  
  29. ?>
Add Comment
Please, Sign In to add comment