URL variable from form to next page

Viewed 98

I am using Coldfusion. My goal is to share data among URL. For example, page-1 shares data (e.g. google.com/variable=123) with page-2. From page-2 I need send this data to page-3 where it is processed as integer (passing it to SQL query).

In page 2 I have form which can submit this data to page 3 but it fails - I get either nothing or the name of variable.

My question: how to temporary store variable from URL on Page 2 and after submit the form send this variable(value) to Page 3?

Part of code which can show my problem:

Page1
<a href="Page1.cfm?category=#variable#">ClickOnMe</a>

Page2
<form action="\Some\Path\Page2.cfm" method="post">

<input name="dataFromURL" value="#URL.category#" type="hidden"> 
<input type="Submit" value="Submit">

</form>

Page3
<cfoutput>
#form.dataFromURL#
</cfoutput>
1 Answers

Consider doing this to try out your variable passing. You need use encoding functions as you are passing variables along. Also web pages use forward slashes

Page1

<cfoutput>
 <a href="Page1.cfm?category=#EncodeForURL(variable)#">ClickOnMe</a>
</cfoutput>

Page2

<cfoutput>
<form action="/Some/Path/Page2.cfm" method="post">

  <input name="dataFromURL" value="#EncodeForHTMLAttribute(URL.category)#" type="hidden">  
  <input type="Submit" value="Submit">

</form>
</cfoutput>

Page3

<cfoutput>
 #EncodeForHTML(form.dataFromURL)#
</cfoutput>

OR

<cfdump var="#form#">
Related