Advertisement
Guest User

Untitled

a guest
Jul 10th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['loginBtn']))
  3. {
  4. $username = $_POST['username'];
  5. $password = $_POST['password'];
  6. $errors = array();
  7. if (empty($username) || empty($password))
  8. {
  9. $errors[] = 'Please fill in all fields';
  10. }
  11.  
  12. if (empty($errors))
  13. {
  14. $SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `accounts` WHERE `Username` = :username AND `Key` = :password");
  15. $SQLCheckLogin -> execute(array(':username' => $username, ':password' => $password));
  16. $countLogin = $SQLCheckLogin -> fetchColumn(0);
  17. if ($countLogin == 1)
  18. {
  19. $SQLGetInfo = $odb -> prepare("SELECT `Username`, `id` FROM `accounts` WHERE `username` = :username AND `Key` = :password");
  20. $SQLGetInfo -> execute(array(':username' => $username, ':password' => $password));
  21. $userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
  22. $_SESSION['Username'] = $userInfo['Username'];
  23. $_SESSION['id'] = $userInfo['id'];
  24. echo 'Successful Login.';
  25. }
  26. }
  27. else
  28. {
  29. echo 'Error: Login Failed.';
  30. }
  31. }
  32.  
  33. }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement