Prevent double insert at same time |
A much cleaner way would be using
Code: type="submit" for your button, and then something like: Code: $("#myform").submit(function(e) { Anyway, for your existing code - try to add this in your final condition: Code: $(this).prop("disabled", true); Oh... and consider whether it's worth taking advantage of the native validation you get when you use "required" tags in your input forms. But I expect you have a reason for doing it the way you are doing it now.
(01-16-2025, 11:20 AM)michalsn Wrote: A much cleaner way would be using hi , i think that with this code i cannot resolve double insert on db , i must insert a validation to control if data with determinate condition are sending to db and if the time is equals i don't insert record... i also think that ci developer must create a standard validation to prevent this by passing an array of value to control (with created_at).
No, checking the "created_at" field for the "equal times" is not the right direction, but good luck.
(01-17-2025, 12:27 AM)michalsn Wrote: No, checking the "created_at" field for the "equal times" is not the right direction, but good luck.created_at is not the right direction if i control only created at but if i control user_id and created_at at same time , how can an user insert two record at same time ?
Because something isn't working correctly.
I was referring to the general idea. If you have to check if a record with the same data has not been added at the same time, then something is not working as it should. If you really have to do this (for whatever reason), you should probably add a unique index to fields (user_id+created_at).
I tink the problem is the server, i run my project on a Windows server with iis and some time it lost session and the user refresh and send post data twice , on 2024 only one time on 113.000 insertion but i would be rove the one too...
Multiple ways of checking for form submission.
How to Prevent Users from Submitting a Form Twice What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(01-25-2025, 04:19 AM)InsiteFX Wrote: Multiple ways of checking for form submission.i prevent client side submission or better i remove button onclick |
Welcome Guest, Not a member yet? Register Sign In |