Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['login']))
- {
- $email = mysqli_real_escape_string($con, $_POST['email']);
- $password = mysqli_real_escape_string($con,$_POST['password']);
- $result = mysqli_query($con, "SELECT * FROM users WHERE email = '" . $email. "'") or die(mysqli_error($con));
- $user = mysqli_fetch_array($result);
- if(mysqli_num_rows($result)>0)
- {
- $logtime = $user['logtime'];
- $counter = $user['counter'];
- $now = date('Y-m-d H:i:s');
- $limit = strtotime("+15 minutes", strtotime($now));
- if($counter <5 || ($counter==5 && $logtime < $now))
- {
- if($counter==5 && $logtime < $now)
- {
- $resetcounter = mysqli_query($con,"UPDATE users SET counter =0 WHERE email='".$email."'") or die(mysqli_error());
- }
- if(password_verify($password, $user['password']))
- {
- $_SESSION['usr_id'] = $user['id'];
- $_SESSION['usr_name'] = $user['name'];
- $_SESSION['email'] = $user['email'];
- $resetcounter = mysqli_query($con,"UPDATE users SET counter =0 WHERE email='".$email."'") or die(mysqli_error());
- header('Location: home/userpage.php');
- }
- else
- {
- if($counter==0)
- {
- $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());
- $errormsg = "The password entered is incorrect.";
- }
- else
- if ($counter <5)
- {
- $updatecounter = mysqli_query($con,"UPDATE users SET counter = (counter+1) WHERE email='".$email."'") or die(mysqli_error());
- $errormsg = "The password entered is incorrect.";
- }
- }
- }
- else
- {
- $errormsg = "<strong>Too many tries - Account locked!! Try again in 15 minutes or click Forgot Password</strong>";
- }
- }
- else
- {
- $errormsg = "The email provided is not registered.";
- }
- }$con->close();
- ?>
- if($counter <5 || ($counter==5 && $logtime < $now))
- {
- if($counter==5 && $logtime < $now)
- {
- if(password_verify($password, $user['password']))
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement