View Single Post
  #44 (permalink)  
Old 02-21-2008, 01:42 AM
prasannavigneshr prasannavigneshr is offline
D-Web Incredible
 
Join Date: Feb 2007
Posts: 1,321
prasannavigneshr is on a distinguished road
Send a message via MSN to prasannavigneshr
Thumbs up ColdFusion Tips & Tricks - Preventing a user from Reloading a page and causing dupli

Preventing a user from Reloading a page and causing duplicate updates


If you ever have a problem where a user submits information to your website and it goes BOOM if they hit the Reload/Refresh button, here is a simple way to prevent it from happening.

Instead of the program that processes the updates also displaying the results of the updates, have the update program use the CFLOCATION tag to redirect to a 3rd program that displays the results.

1. User enters information into a form and hits the Submit button.
2. Submit program executes a program that performs the updates.
3. The Update program uses CFLOCATION to jump to a program that displays the results.
4. The Results program displays the results.

This way, if the user hits the Reload/Refresh button, the only thing that happens is the Results program re-running and not the Update program. Note that if the Update program redirects to the same program that called it via the form Action tag, you will need to force the browser to not cache the document by adding the following line to your <head></head> block:

<META HTTP-EQUIV="expires" CONTENT="Fri, 1 Jan 1990 00:00:00 GMT">
__________________
Prasanna Vignesh
MCPD | Web Developer
Reply With Quote