Results 1 to 3 of 3

Thread: [RESOLVED] php mysql login script with ip ban

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    Resolved [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(); } 
    Richard <><

  2. #2
    Addicted Member BIOSTALL's Avatar
    Join Date
    Apr 2005
    Location
    Northampton, UK
    Posts
    180

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2001
    Posts
    364

    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
  •  



Click Here to Expand Forum to Full Width