|
-
Jul 23rd, 2005, 09:43 AM
#1
Thread Starter
Hyperactive Member
[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(); }
-
Jul 23rd, 2005, 07:07 PM
#2
Addicted Member
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
-
Jul 25th, 2005, 12:55 PM
#3
Thread Starter
Hyperactive Member
Re: php mysql login script with ip ban
thanks,
i have completed it and it works
Last edited by richsmith; Jul 25th, 2005 at 01:21 PM.
Richard <><
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|