How to set login attempts limit in PHP || Disable after 3 failed login attempts with source code

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 11

  • @TechAreaIndia
    @TechAreaIndia  2 роки тому +1

    Please click to subscribe ua-cam.com/users/techareaindia

  • @mraziz3230
    @mraziz3230 Рік тому

    Thank you for the video and was useful.

    • @TechAreaIndia
      @TechAreaIndia  Рік тому +1

      Welcome dear. Thanks for your interest with us.

  • @yogamplanets
    @yogamplanets 2 місяці тому

    Sir please make a video simple calvulator without page reload in php

  • @AvinashChandoli
    @AvinashChandoli Рік тому +1

    "source code please"

    • @TechAreaIndia
      @TechAreaIndia  Рік тому

      Please write to us on techareaindia@gmail.com

    • @j1ro963
      @j1ro963 6 місяців тому

      There no need all u have to do is just copy this code and paste it in urs replace the database with yours:
      $lockout_time = isset($_SESSION['lockout_time']) ? $_SESSION['lockout_time'] : 0;
      $login_attempts = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] : 0;
      if (time() - $lockout_time < 30) {
      echo " You have attempted to log in too many times. Please try again in " . (30 - (time() - $lockout_time)) . " seconds. ";
      } else {
      $result = mysqli_query($con, "SELECT * FROM users WHERE Email='$email'");
      $row = mysqli_fetch_assoc($result);
      if ($row && password_verify($password, $row['Password'])) {
      $_SESSION['valid'] = $row['Email'];
      $_SESSION['username'] = $row['Username'];
      $_SESSION['age'] = $row['Age'];
      $_SESSION['id'] = $row['Id'];
      header("Location: home.php");
      exit;
      } else {

    • @j1ro963
      @j1ro963 6 місяців тому

      } else {
      $result = mysqli_query($con, "SELECT * FROM users WHERE Email='$email'");
      $row = mysqli_fetch_assoc($result);
      if ($row && password_verify($password, $row['Password'])) {
      $_SESSION['valid'] = $row['Email'];
      $_SESSION['username'] = $row['Username'];
      $_SESSION['age'] = $row['Age'];
      $_SESSION['id'] = $row['Id'];
      header("Location: home.php");
      exit;
      } else {
      $login_attempts++;
      if ($login_attempts >= 3) {
      $_SESSION['lockout_time'] = time();
      }
      $_SESSION['login_attempts'] = $login_attempts;
      echo " Wrong Username or Password ";
      echo "Go Back";
      }
      }

  • @j1ro963
    @j1ro963 6 місяців тому +1

    $lockout_time = isset($_SESSION['lockout_time']) ? $_SESSION['lockout_time'] : 0;
    $login_attempts = isset($_SESSION['login_attempts']) ? $_SESSION['login_attempts'] : 0;
    if (time() - $lockout_time < 30) {
    echo " You have attempted to log in too many times. Please try again in " . (30 - (time() - $lockout_time)) . " seconds. ";
    } else {

    • @j1ro963
      @j1ro963 6 місяців тому

      } else {
      $login_attempts++;
      if ($login_attempts >= 3) {
      $_SESSION['lockout_time'] = time();
      }
      $_SESSION['login_attempts'] = $login_attempts;
      echo " Wrong Username or Password ";
      echo "Go Back";
      }

  • @j1ro963
    @j1ro963 6 місяців тому

    } else { $login_attempts++; if ($login_attempts >= 3) { $_SESSION['lockout_time'] = time(); } $_SESSION['login_attempts'] = $login_attempts; echo " Wrong Username or Password "; echo "Go Back"; }