I have a MySQL Table that has a column that will AUTO_INCREMENT, another to store user-submitted data, and another column that defaults to CURRENT_TIMESTAMP.
My INSERT query is:
$query = $db->prepare("INSERT IGNORE INTO `UserData` (`user_data`) VALUES(?)");
$query->bind_param('s', $commentdata);
$query->execute();
However it is still inserting the duplicate values (if a user clicks submit multiple times). What is the best way to prevent this?
IGNOREbut to check if the entry already exists in the DB every time before insertion and tell the user if it's the case.bind_paramcall is wrong.sssmeans there are 3 parameters being bound, but you only have 1 parameter in the query.