Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Return to page it came from

Hi Guys,

I have a header that shows on every page of a site that contains a form that submits to a 'process.cfm' page.

How do I do it such that wherever the header form is submitted from, after the form data gets submitted to the 'process.cfm' page, it returns back to its original page address that submitted it?

I know to use a cflocation tag on the 'process.cfm' page, but how do I get the page url address(including any URL parameters) that the form is coming from so that I can input it into the cflocation tag?(plan to save the page URL address in a hidden form field on the header form page and plug that into the cflocation tag)



Thanks :)
0
CFbubu
Asked:
CFbubu
2 Solutions
 
becraigCommented:
This is the value you need:
<cfoutput>#cgi.HTTP_REFERER#</cfoutput>
0
 
gdemariaCommented:
I would not rely on the referrer variable for your site; you could pass the return url

To me, the preferred way of doing this would be to post each form page to ITSELF and just CFINCLUDE the processing page at the top of each form page.   This has many advantages, although the processing (database actions) may be done in your process.cfm file, you still have individual control in your form file.   So, after the processing you can then redirect to a different page; this can vary for each form file rather than being locked to an action in your process.cfm page.   But most of all.. what if there is an error?   Your form page catches the error and you simply show the form again, with all values still in their fields, even though you have not saved them (due to the error).
0
 
CFbubuAuthor Commented:
Thanks gdemaria and becraig.

gdemaria's answer provided a great deal of clarity to what is the best practice to tackle such an issue.

Thank you for all your trouble providing so much thought into your answer. :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now