Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reload/Refesh browser resubmits the project

Status
Not open for further replies.

florida41

Technical User
May 13, 2004
95
US
I have a form that submits and works but sometimes users hit the Reload button on the Browser after they submit the job and it resubmits the project giving me duplicate projects. How can I prevent this from happening with my Cold Fusion MX using Access 2000 database?

My attempt in the Action page didnt work:

Code:
<cfif not isDefined("project_id")
    You already submitted this project
</cfif>
 
The easiest way around this is to not stay on the form action page. When your user submits the form, have it go to a page that does nothing but process the info, then immediately redirects to another page when it's finished processing.

Example:
Code:
<cfquery>
Insert Form Stuff
</cfquery>

<cflocation url="NewPage.cfm">



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
You may want to use <cfheader> to do your relocation in this case. I've noticed a few times i've refreshed a "non form action" page after cflocation and it still processed the form. likewise if i click back it skips the page the cflocation came from.
<cfheader> will create a new request giving it a distinct line from the last page.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
Thanks, but I have to mail some of the form entry information.

I would like to mail the form entry information out and I put the <cflocation url="NewPage.cfm"> in the last part of my action page below the cfmail. It did redirect the page but I didnt get any mail. Please advise.
 
You'll need to show some code, and you're certain that removing just the cflocation allows the mailing to go through again? Cflocation messes with some tags (not bugs, just tag functions clashing).. but I'm not aware of ever having a CFMAIL problem (related to cflocation, anyway).

If removing the cflocation works... tr this.. (as a test at least) in place of your cflocation

Code:
[red]<cfoutput>[/red]<script>
  <!--
    window.location='location_here.cfm'
  -->
</script>[red]</cfoutput>[/red]

You may have to wrap that in cfoutputs for it to work... that's why the cfoutputs are red.

Also, what version of cold fusion... In some versions of coldfusion, cfmail is evil and does not work at all, or does not work sometimes, or works as long its not overloaded with requests.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thanks everyone. The redirect now works.

Also I could query the database in the beginning of the action page and find a Duplicate on Project Name with the Customer ID and if a Dup then cfabort the page?

Is this something you experienced people do or is this just a judgement call on my part?
 
Here is what my option would be:

Code:
<cfquery name="findDup" datasource="namehere">
select on specific fields that I think should not be duplicated....
</cfquery>

<cfoutput>
<cfif findDup.recordcount gt 0>
<cflocation url="duplicatePagemessage.cfm">
<cfabort>
</cfif>
</cfoutput>


 
Well that's an extra query and its best to do as much with as little as possible.

Proper location-redirection (whether by cflocation/cfheader/javascript method) will kill this problem.

But if you'd like to run another query to be 120% safe, go ahead.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top