Re: How to prevent duplicate record insertion after refreshing php page

From: Date: Wed, 19 May 2010 20:31:09 +0000
Subject: Re: How to prevent duplicate record insertion after refreshing php page
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-305345@lists.php.net to get a copy of this message
Deva wrote:
Hi, If I do refresh after submission of a form, records are getting stored multiple times. I have two pages. /submission-form/ and /thank-you/ I was trying header('Location: /thank-you/'); on submission-form page after successful validation and insertion into db. Still if I do refresh on thank-you page it adds one more record in database. How to prevent it without token?
if you use POST for the form then the user agent should pop up a nice "do you want to send the data again" type dialogue box. if you add a unique key over a few of the columns then this will prevent duplicates at the table level (regardless of the scenario). to handle POST data, well no point me repeating it, see the spec: http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-09#section-7.5 Best, Nathan

« previous php.general (#305345) next »