Reputation: 11
My question is that how to temporally disable a number of buttons/links for user when he clicks one. For example there are 5 buttons: button1, button2.. If he clicks button1 then he can't click any of the buttons again for example 6 hours. Should it be done with php getting user ip, sending it to mysql and "banning" user for 6 hours. Whether clicking the buttons or the url where the buttons are. And after cleaning the specified ip from mysql. The buttons should be banned for the clicked user not for anyone else also refresh or browser restart should grant the option to click any again.
Or should it be done with htaccess somehow.
Extra info: PHP 5.4, mysql. Site also has a basic login system ( http://blog.geotitles.com/2011/07/php-login-script/ ) But I think it would be easier to do separately.
Upvotes: 0
Views: 783
Reputation: 15023
In your users
database table, add a last_button_click
field.
When a user clicks a button, write a record to the database saying the time they clicked it. When reading the page, check if last_button_click
is more than X hours in the past, if so, display the buttons.
If a user shouldn't be able to use duplicate accounts, you'll also want to record his/her IP address in the database and prevent more signups from the same IP address. This isn't foolproof, as users with VPN services like HMA will be able to get around it, but for the majority of users it will work.
You can also look into banning anonymous proxies, VPNs and TOR if needed.
Upvotes: 1
Reputation: 3016
"Banning" a user in a database works fine. When they click the button it should add a ban to the database and when it draws the page again, it should query the database to see if they are banned. If they are, do not show the button, if they are not, show the button.
Upvotes: 0
Reputation: 522015
Upvotes: 3