Re: Refreshing page after form submission

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

 



S.D.Price wrote:
> Hi, I have a form which when submitted adds a record to a DB. However if
> the user clicks back it resubmits the same record.

When you send out the FORM the first time, create a random unique value:
$token = md5(uniqid());
Store that token in your database in a table.
Include that in an INPUT TYPE=HIDDEN with a random unique VALUE="<?=$token?>"
When you process the form, mark that $token in the database as "Submitted"
If they attempt to re-process the same form (IE, the $token is already
"Submitted") then you can do something, or nothing, or whatever you think
best.

> I have tried using cache control to no avail :

Browsers and cache control have a turbulent history, and while they are
really nifty for getting good browsers to refresh content, they are not
real reliable.

If you *need* more control over content caching, change your URLs, perhaps
randomly, when you want content to not be cached.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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