The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
PHP-General - PHP counter for invalid nickname password
Discuss PHP counter for invalid nickname password in the PHP Development forum on Dev Shed. PHP counter for invalid nickname password PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 25th, 2012, 07:06 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 8
Time spent in forums: 1 h 27 m 53 sec
Reputation Power: 0
|
|
|
PHP-General - PHP counter for invalid nickname password
Hello,
Can anybody write for me a very simple example of how I can have a counter on my site? basically, a counter that would inform a user that the wrong nickname and/or password has been entered, 3 times would kick him/her out of the site for 15 minutes.
It might sound like I'm asking too much but I only want the basic principle, I'm not really a newbie but it is definitely the first time I write a counter program in PHP. I wrote a program but my counter variable won't store the updated values, no idea what I'm doing wrong.
Thanks a lot.
|

October 25th, 2012, 07:13 AM
|
|
|
|
You would probably want to keep that count as a column in the database along with the user password, etc. You could use a session variable that does not expire but that might be too easily circumvented depending on how secure you what this to be.
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.
|

October 25th, 2012, 07:23 AM
|
 |
Confused badger
|
|
Join Date: Mar 2009
Location: West Yorkshire
|
|
|
Like gw1500se says, you're going to need two extra fields in your user table; "number_of_tries" and "lockout_datetime"; by default, the number stored in "number_of_tries" is 0. When the user fails to log in, the number in that field is increased by 1 and when it reaches 3, set the "lockout_datetime" to the current date/time and then when the user tries to log back in, if it's still within 15 mins (or whatever) of the lockout time, then tell the user to clear off!
If it's outside of that time then reset the counter to 0 and start again!
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253
"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984
|

October 25th, 2012, 07:37 AM
|
|
|
|
Maybe overkill, but another option is to store the username, datetime, client's IP, etc every time.
Then upon logging in, do a query for the given user and return results just for the past 15 minutes.
|

October 26th, 2012, 07:49 AM
|
|
Registered User
|
|
Join Date: Oct 2012
Posts: 8
Time spent in forums: 1 h 27 m 53 sec
Reputation Power: 0
|
|
|
Guys thanks a lot, based on your suggestions I did the first part with the new columns in MySQL and it worked. The second part would be to do something once the user has reached the max number of attempts, we'll see how that goes.
|

November 2nd, 2012, 12:26 AM
|
|
Registered User
|
|
Join Date: Nov 2012
Posts: 1
Time spent in forums: 17 m 52 sec
Reputation Power: 0
|
|
|
thank you for share
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|