CodeIgniter Forums
Only allow form submission once every X seconds? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Only allow form submission once every X seconds? (/thread-21893.html)



Only allow form submission once every X seconds? - El Forum - 08-24-2009

[eluser]gh0st[/eluser]
Does anyone know where I can find ignited code that would only allow form submissions once every X seconds, and stores the value in either Cookie, Session or Database?

I'm wanting it so that you can only press submit on a form once every 90 seconds.

I'm not sure exactly what such a system is called.

Thanks.


Only allow form submission once every X seconds? - El Forum - 08-24-2009

[eluser]Phil Sturgeon[/eluser]
Quote:I’m wanting it so that you can only press submit on a form once every 90 seconds.

Does this mean the submit form should be disabled (greyed out and unclickable) during this time, or should the form just return a message saying "you may only submit this form once every 90 seconds" like it does on these forums if you search too often?

If you want the submit button to be disabled, that is primarily a JavaScript related issue.

Otherwise, on submit success use $this->session->set_userdata('form_posted', time()); then do a comparison against that time on each submit to see if they should be allowed or not.


Only allow form submission once every X seconds? - El Forum - 08-24-2009

[eluser]Dam1an[/eluser]
I would go with the server side method of storing the submit time in the session and comparing it, as you can easily get around any client side validation using good old firebug