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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux