From: Ashley Sheridan on
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


From: tedd on
At 2:30 PM +0200 5/19/10, Peter Lind wrote:
>>At 5:43 PM +0530 5/19/10, Deva wrote:
>>-snip-
>>
>>Still if I do refresh on
>>thank-you page it adds one more record in database.
>>How to prevent it without token?
>>
>>--
>>Devendra Jadhav
>
>Also, note that you should consider using form tokens, so you don't
>get caught by double submits and cross site form posts, etc.
>
>Regards
>Peter

+1

There's no significant downside to using a token and it works.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com