Re: How to prevent duplicate record insertion after refreshing php page
| From: | Deva | Date: | Wed, 19 May 2010 12:23:20 +0000 |
| Subject: | Re: How to prevent duplicate record insertion after refreshing php page | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305323@lists.php.net to get a copy of this message | ||
Yeah... Done... Got the solution...
You need to do exit(0); after the header()..
die() wont work...
On Wed, May 19, 2010 at 5:42 PM, Ashley Sheridan
<ash@ashleysheridan.co.uk>wrote:
> On Wed, 2010-05-19 at 17:43 +0530, 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?
>
>
>
>
>
> Before inserting the data, perform a query that asks for the count of
> records with that data in it. If you get a record, then don't insert the
> data. This assumes that the data in the row is always unique. If it's
> something like adding a stats record, then have some sort of time comparison
> against the current time and the date entry of the latest matching record..
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
--
Devendra Jadhav
देवेंद्र जाधव