Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

disble th usr fr5 mi whn he inputs th wrng pwd 1 tme usg php

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

disble th usr fr5 mi whn he inputs th wrng pwd 1 tme usg php

Postby annrose » Wed Sep 26, 2012 7:15 pm

Code: Select all
how to disable the user  for 5 minut when he inputs the wrong pwd in only on time using php?
iam trying but iam note access login page pls help...
<?php session_start();?>
<?php error_reporting(E_ALL ^ E_NOTICE);//hiding error using?>
    // let's say the block time is 5 mins
    $failded_waiting_time = 300; // 5 mins
    if(!isset($_SESSION['login_counter'])) $_SESSION['login_counter']=0;
    if($_SESSION['login_counter'] = 1)
       $period = time()-$_SESSION['failed_login'];
    if($period < 500) {
    // do wat you want here like saying u need to wait
    // rediorect to login page
    // if period > $failded_waiting_time
    // reset time
    $_SESSION['failed_login'] = time();
   $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);

   if (empty($myusername) || empty($mypassword))
        $problem = TRUE;
    $sql="SELECT * FROM login WHERE username='$myusername' and password='$mypassword'";
    $_SESSION['myusername'] = $myusername;
   $_SESSION['mypassword'] = $mypassword;
    // register the 1 failed acces time
    if($_SESSION['login_counter'] == 1) {
    $_SESSION['failed_login'] = time();
<form method="post" action="login.php">
<table border="2">
<tr><td>userName</td><td><input type="text" name="username"/></td></tr>
<tr><td>Password</td><td><input type="password" name="password"/></td></tr>
<tr><td><input type="submit" name="sub" value="Login"></td></tr>




New php-forum User
New php-forum User
Posts: 1
Joined: Wed Sep 26, 2012 7:03 pm

Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.