janggu Posted February 13, 2006 Share Posted February 13, 2006 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! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted February 13, 2006 Share Posted February 13, 2006 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 Link to comment Share on other sites More sharing options...
janggu Posted February 13, 2006 Author Share Posted February 13, 2006 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] Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted February 13, 2006 Share Posted February 13, 2006 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...} Quote Link to comment Share on other sites More sharing options...
Dave96 Posted March 27, 2006 Share Posted March 27, 2006 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']; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.