0
<html>
<head>

 </head> 

 <body>
 <div align=center>
 Login
<form name="form1" method="post" action="b.php"> 
   <div align="center"> 
     <table border="1"> 
       <tr> 
         <td width="120">Username :</td> 
         <td width="144"><input name="user" type="text" id="user"></td> 
       </tr> 
       <tr> 
         <td width="120">Mot de passe : </td> 
         <td width="144"><input name="password" type="text" id="password"></td> 
       </tr> 
     </table> 
   </div> 
   <p align="center"> 
     <input type="submit" name="Submit" value="Enter"> 
   </p> 
 </form>

 </body> 
 </html>

file b.php

<?php
$val='1';
setcookie("attempts",$val);
//session_start();
echo "<meta charset=UTF-8>";
if(isset($_POST["user"])&& isset($_POST["password"])&&isset($_COOKIE["attempts"])){
    if(($_POST["user"]=="admin")&&($_POST["password"]=="enter12")&&($_COOKIE["attempts"]))
    {
    setcookie("attempts",1,time()+60*60*24);
    echo "Welcome <b>".$_POST["user"]."</b> !<br/>";
    }
}
    else
    {
    setCookie("attempts",$_COOKIE["attempts"]+1);
    echo "Failed,bad username or password. ".$_COOKIE["attempts"]." attempt to log in.";
    }
    if($_COOKIE["attempts"]==3){
    setcookie("attempts",0,time()+300);
    return true;

}
?>

I think I need to use another setcookie for the time that the user will be lock out of site for 10 minutes.
I just can't figure out how to to lock the page from the user for a limited time periode.
Can someone help me.
thanks

3
Contributors
6
Replies
25
Views
3 Years
Discussion Span
Last Post by CrashDiesel
0

current time minus the time of the event. If the difference between these two is greater than or equal 10 minutes, you must set your user free.

Edited by veedeoo: more info added

0

Thanks for the info, the problem I don't even know how to get the current time.
I'm a newbie

0

thanks,
can this $_SERVER['REQUEST_TIME'] do the job.
Sorry guys, I'll keep trying. I just can't find the solution.
I get what I want, but just can't find the loop to stop the access to the login page for a limited time.

thanks

Edited by CrashDiesel

0

here is a good tutorial on how it can be done without relying too much on session and cookie. If you need help in converting it to mysqli or PDO, please let us know.

Edited by veedeoo: more info added

0

thanks, by my goals here is to do this without mySQL.
Just with php. I'm trying to understand how to set a cookie and lock the page down with the cookie. Its pretty simple, but just can't find the solution.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.