Jump to content


Photo

Generate login error after three attempts


  • Please log in to reply
4 replies to this topic

#1 janggu

janggu
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 13 February 2006 - 07:58 PM

Hello,

I need some help to generate a login error after three attempts. The login is validated by SESSION currently. There is a genetic error message for the login validation but it will say "Please contact admin." after three attemtps.

Thank you!

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 13 February 2006 - 08:04 PM

If your using sessions then create an extra session var, called attempts and increment attempts by 1 every time the user tries to login, then check whether $_SESSION['attampts'] is equal to three, if it is display error messages, else carry on.

#3 janggu

janggu
  • Members
  • PipPip
  • Member
  • 18 posts

Posted 13 February 2006 - 09:31 PM

Thanks for your info but I am not sure how to increment a session (I am still new in PHP). Could you please give me a detailed example?

[!--quoteo(post=345463:date=Feb 13 2006, 08:04 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Feb 13 2006, 08:04 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
If your using sessions then create an extra session var, called attempts and increment attempts by 1 every time the user tries to login, then check whether $_SESSION['attampts'] is equal to three, if it is display error messages, else carry on.
[/quote]


#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 13 February 2006 - 09:35 PM

When the session is created:
$_SESSION['attampts'] = 0;

Then on the login page:

$_SESSION['attampts']++;

if ($_SESSION['attampts'] > 3) {
echo "You have attempted to login too many times";
} else {
...normal code...
}

#5 Dave96

Dave96
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 27 March 2006 - 12:19 AM

I'm also interested in a similar script.

I tried the suggestion above, but the session does not go beyond 1 (it does not get incremented).


edit: got it!

$_SESSION['attampts'] = ++$_SESSION['attampts'];





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users