php - How to limit a form submission rate per user -


i trying limit form's submission rate 1 per user per 120 seconds.

i thinking using $_session variable, i'm not sure how work, , cookies can deleted. guess $_session variable worked around intuitive user logging out , in.

i'm theorizing @ moment not have code.

how around problem?

edit --

the reason user querying because item , bestiary database. need slow down user queries acceptable rate because going on rate of 10 queries/minute or else application may "banned" or denied hour.

$_session , $_cookie variables removed user, , therefore abused them. need store submits somewhere on server. perhaps mysql. check before processing form.

something like

select count(*) attempts, max(submit_time) last form_submits user_id = ? , submit_time > - interval 2 minute 

then

if ($row['attempts'] > 0) {      echo "you must wait " . (time() - strtotime($row['last'])) . " seconds before can submit form again.";     return; } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -