Re: Refreshing page after form submission
| From: | Richard Lynch | Date: | Fri, 17 Dec 2004 16:24:41 +0000 |
| Subject: | Re: Refreshing page after form submission | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-204585@lists.php.net to get a copy of this message | ||
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