I’ve created a form in php and when some people save the result to a mysql database sometimes it saves multiple times but most of the time it only saves one time, as it should.
The code you posted saves only once. So multiple inserts means the code has to be ran multiple times. Maybe like Ryan says they hit the button more than once. Or maybe you do a redirect after the insert, and they hit the back button and it’s inserted again?
You would want it to disable the button via JS (which also helps with the UX since they received feedback that it submitted), as well as, on insert - check and see if the data already exists (since the data going in is identical - because JS can’t be trusted)