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

Passing Info Between Multiple Forms

Status
Not open for further replies.

khurram

IS-IT--Management
Jan 10, 2001
95
CA
Here's the situation:

I have a form where the customer fill in billing/shipping info. Once the info has been validated, I want to pass the billing/shipping info to the next form; the shipping method/payment form-page.

However, I can't seem to pass the info from one page to the next. Here's my first form:

<CFFORM action=&quot;billship.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
<CFINCLUDE template=&quot;inc_newbilladdress.cfm&quot;>
<CFINCLUDE template=&quot;inc_existingbilladdress.cfm&quot;>
</CFFORM>

The form posts to itself because it needs to validate the information. Assuming that I have the variables set to true once the information has been validated, I can I say that I want to post all the information collected to the 'shippay.cfm' form?

For example:
<CFIF ValidatedInfo EQ 0>
<CFFORM action=&quot;billship.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
<CFINCLUDE template=&quot;inc_newbilladdress.cfm&quot;>
<CFINCLUDE template=&quot;inc_existingbilladdress.cfm&quot;>
<CFELSE>
<CFFORM action=&quot;shippay.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
</CFIF>
</CFFORM>

And then it goes to next page. Thanks.
 
Hi Khurram,

What you may want to do is set the Form Variables (After Validation) to Session Variables so that they are available to the next page. The only way to send them through as Form variables would be to set them as Hidden form variables and require another click to submit. It would look like this:

<CFIF ValidatedInfo EQ 0>
<CFFORM action=&quot;billship.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
<CFINCLUDE template=&quot;inc_newbilladdress.cfm&quot;>
<CFINCLUDE template=&quot;inc_existingbilladdress.cfm&quot;>
<CFELSE>
<CFFORM action=&quot;shippay.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
<input name=&quot;variable1&quot;
type=&quot;hidden&quot;
value=&quot;#form.variable1#&quot;>
<input name=&quot;variable2&quot;
type=&quot;hidden&quot;
value=&quot;#form.variable2#&quot;>
... (through all of the form variables)
<cfinput type=&quot;submit&quot; value=&quot;Hit Enter to Continue&quot;>
</CFIF>
</CFFORM>

That would work. It's probably not what you want to do though. Hidden Form variables aren't very secure. Try this instead.

<CFIF ValidatedInfo EQ 0>
<CFFORM action=&quot;billship.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
<CFINCLUDE template=&quot;inc_newbilladdress.cfm&quot;>
<CFINCLUDE template=&quot;inc_existingbilladdress.cfm&quot;>
</CFFORM>

<CFELSE>

<CFLOCK TIMEOUT=&quot;30&quot; NAME=&quot;#Session.SessionID#&quot;>
<CFSET Session.Variable1=&quot;#Form.Variable1#&quot;>
<CFSET Session.Variable2=&quot;#Form.Variable2#&quot;>
...
</CFLOCK>
<CFLOCATION URL=&quot;shippay.cfm&quot; Addtoken=&quot;yes&quot;>
</CFIF>


That will Set you session variables and open the next page. Then to retrieve your variables in Shippay.cfm put:


<CFLOCK TIMEOUT=&quot;30&quot; NAME=&quot;#Session.SessionID#&quot;>
<CFIF #ParameterExists(Session.Variable1)#>
<!--- If one made it they probably all did --->
<CFSET Form.Variable1=&quot;#Session.Variable1#&quot;>
<CFSET Form.Variable2=&quot;#Session.Variable2#&quot;>
...
</CFIF>
</CFLOCK>

I do it like this in case you ever plan on using this same template without sending the variables through session variables. You can still post a Form to this page with the same form variables and it will work either way.

In order for this to work though don't forget to make a file in the directory with these files that is called &quot;application.cfm&quot; and in it you need to have something like:

<CFAPPLICATION name=&quot;MyAPP&quot;
sessionmanagement=&quot;Yes&quot;
SetClientCookies=&quot;No&quot;
SessionTimeout=&quot;#CreateTimeSpan(0,0,10,0)#&quot;
>
<!--- sets timeout for 0 days 0 hours 10 minutes 0 seconds
--->

Basically SessionManagement needs to be turned on. I avoid using cookies as much as possible but that is up to you.

Hope this helps. One way or the other you can get those variables over there!


 
I did think about using Session variables but there are about 25 variables. Are there any performance issues involved. I would problably declare a structure BTW.
 
Session Variables shouldn't slow you down. They aren't really passed anywhere. They are saved on the server, the only thing that is actually passed is the CFID on your URL. Which is another thing you may want to encrypt for security.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top