Forum Moderators: coopster
I am looking for a way to ensure that data is inserted into the db once and not multiple times.
I created a simple form. When a user fills out the form and hits the submit, the data from the form gets inserted into a MySQL db.
Sometimes though, data may be inserted twice and this creates duplicates. Is there any possible way to ensure that data is inserted only once through an INSERT LIMIT?
Script: PHP
Database: MySQL
TIA
Surely the only way to insert the same data twice is to submit the form twice with the same data?
Unless there is something wrong with your code of course...
But what you'd have to do is to check that the data does not exist in the dabase before doing the insert.
Of course, if the form is even one character different (eg a name field: "John Smith" vs "J Smith") then the data is not the same.
if you don't process on the form by submit self or some other foolishness then the user would have to go back and resub, making it more involved
you can tag it with an id to carry through the process, though the user can always go back through the process and resub unless you check for specific info as mentioned