PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 25th, 2012, 07:06 AM
knightmetal knightmetal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 knightmetal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #2  
Old October 25th, 2012, 07:13 AM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,867 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Week 5 Days 9 h 6 m 6 sec
Reputation Power: 581
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.

Reply With Quote
  #3  
Old October 25th, 2012, 07:23 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
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

Reply With Quote
  #4  
Old October 25th, 2012, 07:37 AM
NotionCommotion NotionCommotion is offline
Contributing User
Click here for more information.
 
Join Date: Sep 2006
Posts: 1,464 NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level)NotionCommotion User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 6 h 21 m 9 sec
Reputation Power: 526
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.

Reply With Quote
  #5  
Old October 26th, 2012, 07:49 AM
knightmetal knightmetal is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 knightmetal User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
  #6  
Old November 2nd, 2012, 12:26 AM
scofieldtaylor scofieldtaylor is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 1 scofieldtaylor User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 m 52 sec
Reputation Power: 0
thank you for share

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP-General - PHP counter for invalid nickname password

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap