richsmith
Jul 23rd, 2005, 09:43 AM
hi there,
i have just made a log in script which works well, however i would like to be able to make it so that if someone attempts to login but fails 3 times then their ip is banned for a certain amount of time:
i have a table with bannedip, time(type datetime) and id,
i dont really know how to do this.
here is my code:
if( (!$username) or (!$password) )
{ header("Location:$HTTP_REFERER"); exit(); }
require ("conn.php");
$sql="select * from aplace where username=\"$username\" and password = password(\"$password\")";
$rs=mysql_query($sql,$conn)
or die("Error in query");
$num = mysql_numrows($rs);
if($num != 0)
{ $msg = "Welcome $username - you have logged in";
setcookie("user","in");}
else
{ header("Location:$HTTP_REFERER"); exit(); }
i have just made a log in script which works well, however i would like to be able to make it so that if someone attempts to login but fails 3 times then their ip is banned for a certain amount of time:
i have a table with bannedip, time(type datetime) and id,
i dont really know how to do this.
here is my code:
if( (!$username) or (!$password) )
{ header("Location:$HTTP_REFERER"); exit(); }
require ("conn.php");
$sql="select * from aplace where username=\"$username\" and password = password(\"$password\")";
$rs=mysql_query($sql,$conn)
or die("Error in query");
$num = mysql_numrows($rs);
if($num != 0)
{ $msg = "Welcome $username - you have logged in";
setcookie("user","in");}
else
{ header("Location:$HTTP_REFERER"); exit(); }