eg. A registration form can only be used x amount of times?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
If you're submitting the form via ajax this is a pretty good resource.
By used x amount of times I presume you actually mean submitted x amount of times. You could have a session counter that increments each time the form is submitted and does not pass validation, and prevents further submission attempts when the limit is reached.
Quick and Dirty Solution For PHP.
Everytime they visit a page, it increments the counter. Too many times means the page
die()
s. You can choose to put this code in a spot where it will only be executed when someone submits the form.It resets the count every so often.
Known Bugs: Clearing Cookies breaks it, having cookies off breaks it.
This is given you want a per user solution. If it is a whole site thing, just comment and I'll delete.
Unfortunately, there isn't a solid method here. The best way would be to store a cookie, but obviously they can clear cookies. You could try making another unique string/id of some sort by combining (md5) their IP address with their user-agent (browser,etc), then storing that in the database, but that will probably deny some people who shouldn't be denied.
Yes. Have the form processing page record to a database how many times it's been used, and have it disable the form when x uses are recorded.