[RESOLVED] php mysql login script with ip ban
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:
PHP 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(); }
Re: php mysql login script with ip ban
The way i would do it is to use a session variable that would increase by one each time the user fails to log in. When this session variable reaches 3, Add their IP address to your table.
Just ask if you need further explanation..
Hope that helps,
BIOSTALL
Re: php mysql login script with ip ban
thanks,
i have completed it and it works