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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variables between Multiple Pages

Status
Not open for further replies.

khurram

IS-IT--Management
Jan 10, 2001
95
CA
Does anyone know how to pass variables between pages with using URL's and session variables?

Basically, I have a browser who is creating an account and I want to pass the login and password from one page to the next.

The reason I don't use forms is because the browser enters the information on one page, the info passes to an action page and then gets redirected to the appropriate page. From what I've seen, you can't pass the inputs from a form-actionpage-form, but I am probably wrong (I hope I am because it'll make things easier.)

Thanks in advance.
 
In your action page, use a <cf_include> to include the next form after you do your action processing:

Say you have three pages, FORM1 (the first input form), FORM2 (the action page for FORM1) and FORM3 (displays the next form:

FORM1.CFM
<cfform action=&quot;form2.cfm&quot;>
...
</cfform>

FORM2.CFM
<Process whatever you need to>
<cfinlcude template=&quot;FORM3.cfm&quot;>

Make sense? You might also checkout .

After reading about and learning the FuseBox standard, my ColdFusion productivity went through the roof. It takes a little to get used to, but once you start using it, you wonder how you ever programmed any other way. It makes what you are trying to do dirt simple because you are always posting to the same page (index.cfm) and just calling whatever pages you need via cfincludes based on a &quot;fuseaction&quot;. Try it, you'll like it.

Tim
 
khurram ...
you should use forms ;) you can pass variables between pages usin' sessions, and you can do that using urls, but .. in case you wanna pass a secured values, don't use urls for that because your data will be shown for users!!

if you wanna use sessions for that, all you have to do is the followin':
1) create a file called (application.cfm) and locate it on the root of your application.
2) inside application.cfm, write the followin' tag:
<cfapplication name=&quot;somename&quot; sessionmanagement=&quot;yes&quot; sessiontimeout=&quot;#CreateTimespan(0, 0, 20, 0)#&quot;>
3) now you can use sessions in any of your pages. To set a session variable:
<cfset session.first_name = &quot;bebbero&quot;>
<cfset session.amount = 123>
and so on ..
To retreive the value of the session:
<cfoutput>
<cfset var_amount = #session.amount#>
#session.amount# <!--- this displays the result on the screen --->
</cfoutput>

if you wanna pass variables via the url:
<cfset ID = 6>
<cfoutput>
<a href=&quot;index2.cfm?ID=#ID#&quot;>Click here</a>
</cfoutput> <bebbero></bebbero>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top