Advertisement
Guest User

Untitled

a guest
Mar 16th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. <?php
  2. if (!($user -> LoggedIn()))
  3. {
  4. if (isset($_POST['loginBtn']))
  5. {
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8. if (!empty($username) && !empty($password))
  9. {
  10. if (!ctype_alnum($username) || strlen($username) < 4 || strlen($username) > 15)
  11. {
  12. echo '<div class="g_12"><div class="alert alert-danger"><strong>ERROR</strong>:Invalid username format</div></div>';
  13. }
  14. else
  15. {
  16. $SQLCheckLogin = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `username` = :username AND `password` = :password");
  17. $SQLCheckLogin -> execute(array(':username' => $username, ':password' => SHA1($password)));
  18. $countLogin = $SQLCheckLogin -> fetchColumn(0);
  19. if ($countLogin == 1)
  20. {
  21. $SQLGetInfo = $odb -> prepare("SELECT `username`, `ID`,`status` FROM `users` WHERE `username` = :username AND `password` = :password");
  22. $SQLGetInfo -> execute(array(':username' => $username, ':password' => SHA1($password)));
  23. $userInfo = $SQLGetInfo -> fetch(PDO::FETCH_ASSOC);
  24. if ($userInfo['status'] == 0)
  25. {
  26. $_SESSION['username'] = $userInfo['username'];
  27. $_SESSION['ID'] = $userInfo['ID'];
  28. $Query = $odb-> query("INSERT INTO `logins` VALUES ('$username','$ip','$newcount','$time')");
  29. echo '<div class="g_12"><div class="alert alert-success"><strong>Success</strong>: You are now being redirected to Dashboard</div></div><meta http-equiv="refresh" content="2;url=index.php">';
  30. }
  31. else
  32. {
  33. echo '<div class="g_12"><div class="alert alert-danger"><strong>ERROR</strong>: Your user was banned</div></div>';
  34. }
  35. }
  36. else
  37. {
  38. echo '<div class="g_12"><div class="alert alert-danger"><strong>ERROR</strong>: Login Failed</div></div>';
  39. }
  40. }
  41. }
  42. else
  43. {
  44. echo '<div class="g_12"><div class="alert alert-danger"><strong>ERROR</strong>: Please fill in all fields</div></div>';
  45. }
  46. }
  47. }
  48. else
  49. {
  50. header('location: index.php');
  51. }
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement