Re: diplicate entries

From: Date: Fri, 11 Jun 2004 11:55:49 +0000
Subject: Re: diplicate entries
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-34738@lists.php.net to get a copy of this message
"Bobo Wieland" <dev@elstudion.com> wrote in message news:001801c44fa9$a8f089a0$5cea1e0a@uedamultimedia... > Hi! > > What is the best way to check if a record allready exists in a msql-db from > php in the case of when the same form is submited twice beacuse of the > "refresh"-button? > Should I allways check the db for the same entry, or is there some esier way > to prevent the user from submiting a form more then once? > Btw, is it possible for an sql-query to stop halfway through (if the server > goes down or something)? Please don't hijack threads! As to your duplicate form submits: This is usually prevented by using a hidden form element with a randomly generated token (string). When the form is submitted check if the token already exists in a session array - if not this is the first submit so store the token in the array and process the form. If the same form is re-submitted the token will be found in the session array and therefore the form should not be processed. IMPORTANT: When creating the random token check if a token with this value already exists in the session array. Hope this helps. Regards, Torsten Roehr

« previous php.db (#34738) next »