Is it possible to delay submitting? Sometimes users hammer the submit button and they submit too much data in too little time which passes some php restricts and lags the site.
You could have a basic limit to submitting and store it in a session variable and once the user has gone over the limit, stop displaying the submit button. Same as above, but could be done with cookies. Another method would be to use JavaScript to disable the submit button when the onMouseClick() event has been triggered. Thats all i can think of for now, Regards, Steve
They don't let the page usually load, they just hammer the button and it usually accepts data 4 times in a second. I'd want the max be 2 times in a second. The page is built up like that: let's say the submit button adds +1 to $thing until $thing =< 10, but with hammering it sometimes ignores that and they can get $thing up to 15. I don't want to take away the submit button, and they could always refresh...
Basically you need a last access time stored for each user, and limit the submissions for 5 seconds. I'm guessing this is for some kind of game. Also, you could implement a ban scheme where if you submit too many times, your IP/username gets banned for so many mins/hours
It's not that hard, just call a Javascript procedure each onSubmit. I'm not going into detail, last time you asked for help via PM, I spent a while helping you and you didn't even bother to say thanks or tell me that the code worked.
Not all browsers have javascript enabled, so that is a flawed solution if he is having a hammering for his server. Plus, if the users are sending headers rather than submitting via the button, it won't work either
I didn't realize you wanted a reply, my message had a thanks in advance... I got the problem solved before you replied me and it was similar to your code.... I appreciate your help. Yes.... After every move on the site the time is stored in the user's time field... I don't want to ban or bug the users in any way. I just want the information not go through that quickly. Two submissions per second would be perfect. This would be really useful if it could be implemented globally over the whole site as well.
I suppose you could use javascript, and have the button disabled by default. then on page load wait 2 seconds to make it active or w/e. Why does a user need to access the page 2 times per second?!?
Well it's a game... And they have to do things fast to stay alive etc... Maybe there is something in php.ini?
I can't see how a user needs to access twice a second...plus everyone has different line speeds, so its not really fair on the users with the inferior internet connections IMO. regarding the php.ini, I don't know of any setting, and to be fair, its more likely an apache setting than a php one
put : sleep(3); ...at the top of the php file that processes the form. If this is no good you should keep an array stack in a session variable. When the user submits, array_push an entry onto the stack with a timestamp, if they have more than X entries on the stack in X seconds then die("you suck balls").
If you put sleep than the PHP code will not be displayed for 3 seconds, so here there isn't just a delay of hitting the submit button but just the whole php code that has to be dislayed. If this is what you want than sleep() is the best function to use.