Jump to content

Archived

This topic is now archived and is closed to further replies.

janggu

Generate login error after three attempts

Recommended Posts

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!

Share this post


Link to post
Share on other sites
If your using sessions then create an extra session var, called [b][i]attempts[/i][/b] 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.

Share this post


Link to post
Share on other sites
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) [snapback]345463[/snapback][/div][div class=\'quotemain\'][!--quotec--]
If your using sessions then create an extra session var, called [b][i]attempts[/i][/b] 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]

Share this post


Link to post
Share on other sites
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...
}

Share this post


Link to post
Share on other sites
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'];

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.