<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

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.

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

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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.