Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once("include/database.php");
  4.  
  5. if (isset($_POST['submit'])) {
  6. $errMsg = '';
  7. //username and password sent from Form
  8. $username = $_POST['user_login'];
  9. $password = $_POST['user_password'];
  10.  
  11. if ($username == '') {
  12. $errMsg .= 'You must enter your Username<br>';
  13. }
  14.  
  15. if ($password == '') {
  16. $errMsg .= 'You must enter your Password<br>';
  17. }
  18.  
  19.  
  20. if ($errMsg == '') {
  21. $records = $db->prepare('SELECT user_id ,user_login ,user_password FROM users WHERE user_login = :username');
  22. $records->bindParam(':username', $username );
  23. $records->execute();
  24. $results = $records->fetch(PDO::FETCH_ASSOC);
  25. if (count($results) > 0 && password_verify($password, $results['user_password'])) {
  26. $_SESSION['user_login'] = $results['user_login'];
  27. header('location:test.php');
  28. exit;
  29. } else {
  30. $errMsg .= 'Username and Password are not found<br>';
  31. }
  32. }
  33. }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement