One way I have been avoiding upwanted duplicates if by generating a random number when users enters HTML form for the first time or after database update. I pass this number from page to page on as a hidden value on the form submit button. I also put this value in a $_SESSION variable. When it is time to update the database, I check that $_SESSION value = get/post value. If equal, program will insert data to database, show confirmation screen and generate new random number. If not equal, program will give error message, generate a new random number and show new blank form.
Code: Select all
$_SESSION['guestAddedToken'] = $this->fnGenerateToken();