Preventing Duplicate Form Submissions to MySQL Database
Posted: Sun Sep 06, 2009 6:13 pm
Hello. I have a form that submits information to a backend SQL database using AJAX/PHP. The form consists of two dropdown boxes. The value of each dropdown box and the username of the logged in user are inserted into a SQL table upon submitting the form. How do I prevent the user from creating duplicate submissions?
For example, say the user chooses the make of a car from dropdown #1, and the model of a car from dropdown #2. The values that get written to the table are:
Ford, Taurus, Mike
But the problem is that Mike can resubmit the form and add another Ford model. The next time he submits, these values are written to the table:
Ford, Focus, Mike
How can I set up the PHP to check if Mike has already submitted a Ford and prompt him to overwrite the record so there are no duplicate Ford submissions for user Mike????
For example, say the user chooses the make of a car from dropdown #1, and the model of a car from dropdown #2. The values that get written to the table are:
Ford, Taurus, Mike
But the problem is that Mike can resubmit the form and add another Ford model. The next time he submits, these values are written to the table:
Ford, Focus, Mike
How can I set up the PHP to check if Mike has already submitted a Ford and prompt him to overwrite the record so there are no duplicate Ford submissions for user Mike????