Advertisement
Guest User

Untitled

a guest
Sep 12th, 2017
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. if (isset($_POST['login']))
  2. {
  3.  
  4. $email = mysqli_real_escape_string($con, $_POST['email']);
  5. $password = mysqli_real_escape_string($con,$_POST['password']);
  6.  
  7.  
  8. $result = mysqli_query($con, "SELECT * FROM users WHERE email = '" . $email. "'") or die(mysqli_error($con));
  9. $user = mysqli_fetch_array($result);
  10. if(mysqli_num_rows($result)>0)
  11. {
  12.  
  13. $logtime = $user['logtime'];
  14. $counter = $user['counter'];
  15. $now = date('Y-m-d H:i:s');
  16. $limit = strtotime("+15 minutes", strtotime($now));
  17. if($counter <5 || ($counter==5 && $logtime < $now))
  18. {
  19. if($counter==5 && $logtime < $now)
  20. {
  21. $resetcounter = mysqli_query($con,"UPDATE users SET counter =0 WHERE email='".$email."'") or die(mysqli_error());
  22. }
  23.  
  24. if(password_verify($password, $user['password']))
  25. {
  26. $_SESSION['usr_id'] = $user['id'];
  27. $_SESSION['usr_name'] = $user['name'];
  28. $_SESSION['email'] = $user['email'];
  29.  
  30.  
  31. $resetcounter = mysqli_query($con,"UPDATE users SET counter =0 WHERE email='".$email."'") or die(mysqli_error());
  32. header('Location: home/userpage.php');
  33. }
  34. else
  35. {
  36. if($counter==0)
  37. {
  38. $updatecounter = mysqli_query($con,"UPDATE users SET counter = (counter+1), logtime ='".date('Y-m-d H:i:s',$limit)."' WHERE email='".$email."'") or die(mysqli_error());
  39. $errormsg = "The password entered is incorrect.";
  40. }
  41. else
  42. if ($counter <5)
  43. {
  44. $updatecounter = mysqli_query($con,"UPDATE users SET counter = (counter+1) WHERE email='".$email."'") or die(mysqli_error());
  45. $errormsg = "The password entered is incorrect.";
  46. }
  47. }
  48. }
  49. else
  50. {
  51. $errormsg = "<strong>Too many tries - Account locked!! Try again in 15 minutes or click Forgot Password</strong>";
  52. }
  53.  
  54.  
  55. }
  56. else
  57. {
  58. $errormsg = "The email provided is not registered.";
  59. }
  60.  
  61. }$con->close();
  62. ?>
  63.  
  64. if($counter <5 || ($counter==5 && $logtime < $now))
  65. {
  66. if($counter==5 && $logtime < $now)
  67. {
  68.  
  69. if(password_verify($password, $user['password']))
  70. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement