Ask a Question related to Macromedia ColdFusion, Design and Development.
-
lazerbrains555 #1
Carrying a variable through 3 page form
I have a three page form.??When you link to the first page from a generated
email the URL looks like this:
[url]https://www.mydomain.com/secure/page.cfm?m=I15856157&s=C3[/url]
What I need to do is get the code after the s= from the first page to the last
page so I can put it into a database.??I think it has something to do with
hidden variables, but I am not sure how to get them to work.??Also this code
only sometimes exists in the link os It will have to be in an if
statement.??Any ideas?
:confused;
lazerbrains555 Guest
-
ASP Page Manipulated by Form Variable
I have an ASP page containing data from a recordset. I would like help doing the following: When the user first opens the page, they see all of the... -
Carrying value to the next page:
Guys, I created a form (HTML) with 3 text boxes Text1, Text2 and text3. At the end of the form there is a submit button that open another page with... -
how to transfer the form variable to other page afterusing user validating?
I want to get a form variable which is user's id, and use it in the other asp page, if the user pass the validating. I used the DW's logon-in... -
Carrying PHP Variables From Web Page To Web Page
I was reading about PHP variable scoping - it doesn't seem to support carrying any variables from one web page to another - how is this usually... -
Carrying a variable
I am using PHP 4.3.0 The way that I usually carry variables from one page to another is $Unit = ($_GET); This is the page that is referencing... -
BerkTheTurk #2
Re: Carrying a variable through 3 page form
If you are submitting your forms to get from one page to another you can put this before the submit button
<input type="hidden" name="myvariable" value="myvalue">
Hope this helps
BerkTheTurk Guest
-
lazerbrains555 #3
Re: Carrying a variable through 3 page form
OK, what I do have is:
Page 1:
<cfif ParameterExists(url.s)><cfoutput><input type=hidden name=ConversionCode
value="#url.s#"></cfoutput></cfif>
Page 2:
<input type=hidden name="ConversionCode" value="#form.ConversionCode#">
Page 3: Insert Query
<cfquery datasource=DB name="WritePeople">
INSERT INTO wPeople (Email, strSalutation, strFirstName, strLastName,
strCompanyName, strAddress, strAddress2, strCity, strState, strZip,
strPostalCode, strRegion, strCountry, PhoneDay, MemberType,
MembershipTerm, Creator, SourceKey, ConversionCode, strNotes, CreationDate)
VALUES ('#Email#', '#strSalutation#', '#strFirstName#', '#strLastName#',
'<cfif
ParameterExists(form.ClubName)>#form.ClubName#<cfe lse>#form.strCompanyName#</cfi
f>',
'#strAddress#', '#strAddress2#', '#strCity#', '#strState#', '#strZip#',
'#strPostalCode#', '#strRegion#', '#strCountry#', '#Phone#',
'<cfif IsDefined("MemberCategory")>#MemberCategory#<cfels e></cfif>',
'<cfif IsDefined("Years")>#Years#<cfelse></cfif>', 'WEB-JOIN', '#Source#',
'<cfif IsDefined("ConversionCode")>#ConversionCode#<cfels e></cfif>',
'<cfif IsDefined("Other")>#Trim(form.Notes)#
#form.Other#<cfelse>#Trim(form.Notes)#</cfif>', '#TodaysDate#')
</cfquery>
It is actually inserting the text "#Conversio" into the database because that
field only has a 10 character limit. I need it to actually insert the 2
character variable instead.
Any Ideas?
:confused;
lazerbrains555 Guest
-
mxstu #4
Re: Carrying a variable through 3 page form
Try putting the single quotes around the form values, not the whole CFIF
statement
... ,<cfif
IsDefined("form.ConversionCode")>'#form.Conversion Code#'<cfelse>''</cfif>, ...
Also, ParameterExists() is deprecated so use IsDefined() instead and make sure
to put quotes around the variable name
<cfif IsDefined("URL.s")>
mxstu Guest
-
lazerbrains555 #5
Re: Carrying a variable through 3 page form
Are you talking about doing the quote thing on the Page 3 Query or on one of the other pages? I did what you suggested on page 3 but it gave me an SQL error. Any other ideas?
:frown;
lazerbrains555 Guest
-
mxstu #6
Re: Carrying a variable through 3 page form
Repost the new INSERT query that you on page 3 and the full error message that was returned.
mxstu Guest
-
lazerbrains555 #7
Re: Carrying a variable through 3 page form
Here is the page 3 query:
<cfquery datasource=db name="WritePeople">
INSERT INTO wPeople (Email, strSalutation, strFirstName, strLastName,
strCompanyName, strAddress, strAddress2, strCity, strState, strZip,
strPostalCode, strRegion, strCountry, PhoneDay, MemberType,
MembershipTerm, Creator, SourceKey, ConversionCode, strNotes, CreationDate)
VALUES ('#Email#', '#strSalutation#', '#strFirstName#', '#strLastName#',
'<cfif
ParameterExists(form.ClubName)>#form.ClubName#<cfe lse>#form.strCompanyName#</cfi
f>',
'#strAddress#', '#strAddress2#', '#strCity#', '#strState#', '#strZip#',
'#strPostalCode#', '#strRegion#', '#strCountry#', '#Phone#',
'<cfif IsDefined("MemberCategory")>#MemberCategory#<cfels e></cfif>',
'<cfif IsDefined("Years")>#Years#<cfelse></cfif>', 'WEB-JOIN', '#Source#',
<cfif IsDefined("ConversionCode")>'#ConversionCode#'<cfe lse></cfif>,
'<cfif IsDefined("Other")>#Trim(form.Notes)#
#form.Other#<cfelse>#Trim(form.Notes)#</cfif>', '#TodaysDate#')
</cfquery>
The error message is:
ODBC Error Code = 42000 (Syntax error or access violation)
[TCX][MyODBC]You have an error in your SQL syntax near ' 'TEST ',
'2005-06-23')' at line 7
Line 7 of the query is the line that I changed.
I also changed Page 1 to:
<cfif IsDefined("url.s")><cfoutput><input type=hidden name=conversioncode
value="#url.s#"></cfoutput></cfif>
And Page 2 is the same:
<input type=hidden name="ConversionCode" value='#form.ConversionCode#'>
And it inserts the actual text of this "#form.Conv" instead of the actual
variable.
Any other ideas?
:confused;
lazerbrains555 Guest
-
mxstu #8
Re: Carrying a variable through 3 page form
There are a few problems on page 3
1) In your query, you have no value is the CFELSE section
....,<cfif IsDefined("ConversionCode")>'#ConversionCode#'<cfe lse>no value
here</cfif>, ...
You must specify a value or an error will occur if "form.ConversionCode" is
not defined.
- Either insert an empty string like this:
....,<cfif IsDefined("ConversionCode")>'#ConversionCode#'<cfe lse>''</cfif>,
....
- OR insert a NULL value (if the column accepts them) like this:
....,<cfif IsDefined("ConversionCode")>'#ConversionCode#'<cfe lse>NULL</cfif>,
....
2) Looks like you're missing a CFOUTPUT on page 2, which why it is inserting
the literal value '#form.ConversionCode#'
<!--- add cfoutput to page 2 --->
<cfoutput>
<input type="hidden" name="ConversionCode" value="#form.ConversionCode#">
</cfoutput>
3) If you're using an ODBC connection, its better to use the CreateODBCDate()
function when inserting dates
Use this syntax (note: there are no single quotes around the value)
..., #CreateODBCDate(TodaysDate)# )
So instead of this:
..., '#TodaysDate#' )
mxstu Guest
-
lazerbrains555 #9
Re: Carrying a variable through 3 page form
I put in the 'NULL' values in page three and I inserted the <cfoutput> tags
into page 2, but now I get this error on page two:
An error occurred while evaluating the expression:
#form.ConversionCode#
Error near line 238, column 51.
------------------------------------------------------------------------
Error resolving parameter FORM.CONVERSIONCODE
The specified form field cannot be found. This problem is very likely due to
the fact that you have misspelled the form field name.
The error occurred while processing an element with a general identifier of
(#form.ConversionCode#), occupying document position (238:50) to (238:70) in
the template file D:\blah\blahblah\HTDOCS\blah\page2.CFM.
Any Idea why it is not passing the variable from page one to page two?
lazerbrains555 Guest
-
mxstu #10
Re: Carrying a variable through 3 page form
You're not checking on page 2 to determine whether the form variable exists,
the way you do on pages 1 and 3.
<!--- from your page 1 --->
<cfif ParameterExists(url.s)><cfoutput><input type=hidden name=ConversionCode
value="#url.s#"></cfoutput></cfif>
You need to add an IsDefined() check on page 2. Also check the form on page 1
and make sure the method="post' and not "get". If the method is "get" the
values will be passed as URL variables and not FORM variables which will cause
an error.
mxstu Guest
-
lazerbrains555 #11
Re: Carrying a variable through 3 page form
Would I look for 'form.s' to be defined or 'form.ConversionCode' to be defined?
lazerbrains555 Guest
-
mxstu #12
Re: Carrying a variable through 3 page form
If the form on page 1 uses method="post" you would check for the existence of
"form.ConversionCode" on page 2.
I think it would much simpler to always create the "ConversionCode" field on
page 1. Then simply check the value in your final query on page 3. If the
value is not an empty string, then insert the specified ConversionCode.
Otherwise, insert NULL. For example:
<!--- page 1 --->
<cfoutput>
<input type="hidden" name="ConversionCode" <cfif
IsDefined("url.s")>value="#URL.s#"</cfif>>
</cfoutput>
<!--- page 2 --->
<cfoutput>
<input type="hidden" name="ConversionCode" value="#form.ConversionCode#">
</cfoutput>
<!--- page 3 --->
<cfoutput>
<cfif Len(Trim(form.ConversionCode)) GT
0>'#ConversionCode#'<cfelse>NULL</cfif>,
</cfoutput>
mxstu Guest
-
lazerbrains555 #13
Re: Carrying a variable through 3 page form
I changed all code to match that which you suggested and it is still giving me
the same error on page two:
An error occurred while evaluating the expression:
#form.ConversionCode#
Error near line 239, column 52.
------------------------------------------------------------------------
Error resolving parameter FORM.CONVERSIONCODE
The specified form field cannot be found. This problem is very likely due to
the fact that you have misspelled the form field name.
The error occurred while processing an element with a general identifier of
(#form.ConversionCode#), occupying document position (239:51) to (239:71) in
the template file D:\WSDOCS\BLAHBLAH\HTDOCS\BLAHBLAH\PAGE2.CFM.
How is it not passing the variable? Any more ideas?
lazerbrains555 Guest
-
mxstu #14
Re: Carrying a variable through 3 page form
Did you check the form methods and make sure they are all using method "post" and not "get"?
mxstu Guest
-
BerkTheTurk #15
Re: Carrying a variable through 3 page form
When you are using hidden inputs try putting <cfoutput></cfoutput> tags around it
<cfoutput>
<input type=hidden name="ConversionCode" value='#form.ConversionCode#'>
</cfoutput>
BeRk
BerkTheTurk Guest
-
lazerbrains555 #16
Re: Carrying a variable through 3 page form
I have tried all suggestions on this post and I still can't get that url value
into the database. It either inserts nothing or it inserts the actual text
"#ConversionCode#". I don't know what else to do?:confused;
lazerbrains555 Guest
-
BerkTheTurk #17
Re: Carrying a variable through 3 page form
Could you post the last version of your code? It is kinda hard to figure it out from all the postings.
BeRk
BerkTheTurk Guest
-
JMGibson3 #18
Re: Carrying a variable through 3 page form
Berk is correct, going all the way back to your 3rd post where you say:
Page 2:
<input type=hidden name="ConversionCode" value="#form.ConversionCode#">
It should be:
<cfoutput>
<input type=hidden name="ConversionCode" value="#form.ConversionCode#">
</cfoutput>
That's why the name #form.ConversionCode# shows up later rather than it's
value. You can actually see it sitting there on Page 2 if you do a View
Source. I know because i do this myself ALL the time (also on URL's). I'm so
used to doing CFINPUT's where the <cfoutput> is not needed that when I
occasionally use a regular <INPUT> it slips right by me. (I'm also constantly
doing <CFIF .. = ..> rather than <CFIF .. EQ ..> ). :D
JMGibson3 Guest
-
lazerbrains555 #19
Re: Carrying a variable through 3 page form
Page 1:
<cfform action="join2.cfm" enctype="x-www-form-encoded" method="post"
name="join">
<cfoutput>
<input type="hidden" name="ConversionCode" <cfif
IsDefined("url.s")>value="#URL.s#"</cfif>>
</cfoutput>
Plus other form elements.
Page 2:
<cfif IsDefined("form.ConversionCode")>
<cfoutput>
<input type=hidden name="ConversionCode" value="#form.ConversionCode#">
</cfoutput>
</cfif>
plus other form elements.
Page 3: (the insert query)
<cfset TodaysDate = '#DateFormat(now(), "YYYY-MM-DD")#'>
<cfquery datasource=ATL name="WritePeople">
INSERT INTO wPeople (Email, strSalutation, strFirstName, strLastName,
strCompanyName, strAddress, strAddress2, strCity, strState, strZip,
strPostalCode, strRegion, strCountry, PhoneDay, MemberType,
MembershipTerm, Creator, SourceKey, ConversionCode, strNotes, CreationDate)
VALUES ('#Email#', '#strSalutation#', '#strFirstName#', '#strLastName#',
'<cfif
ParameterExists(form.ClubName)>#form.ClubName#<cfe lse>#form.strCompanyName#</cfi
f>',
'#strAddress#', '#strAddress2#', '#strCity#', '#strState#', '#strZip#',
'#strPostalCode#', '#strRegion#', '#strCountry#', '#Phone#',
'<cfif IsDefined("MemberCategory")>#MemberCategory#<cfels e></cfif>',
'<cfif IsDefined("Years")>#Years#<cfelse>NULL</cfif>', 'WEB-JOIN',
'#Source#',
'<cfif
IsDefined("ConversionCode")>#form.ConversionCode#< cfelse>NULL</cfif>',
'<cfif IsDefined("Other")>#Trim(form.Notes)#
#form.Other#<cfelse>#Trim(form.Notes)#</cfif>', '#TodaysDate#')
</cfquery>
It seems like this should work but for some reason it inserts everything
correctly except the "ConversionCode".
Any ideas?
lazerbrains555 Guest
-
lazerbrains555 #20
Re: Carrying a variable through 3 page form
Originally posted by: JMGibson3
Berk is correct, going all the way back to your 3rd post where you say:
Page 2:
<input type=hidden name="ConversionCode" value="#form.ConversionCode#">
It should be:
<cfoutput>
<input type=hidden name="ConversionCode" value="#form.ConversionCode#">
</cfoutput>
That's why the name #form.ConversionCode# shows up later rather than it's
value. You can actually see it sitting there on Page 2 if you do a View
Source. I know because i do this myself ALL the time (also on URL's). I'm so
used to doing CFINPUT's where the <cfoutput> is not needed that when I
occasionally use a regular <INPUT> it slips right by me. (I'm also constantly
doing <CFIF .. = ..> rather than <CFIF .. EQ ..> ). :D
I did end up doing that and now I get no value at all. I'm not sure why this
seems like it should be pretty simple. Just define the variable and carry
throught the pages until the end and insert it. I don't know what is goofing
it up. There are other form elements but none of them are written to affect
the ConversionCode variable. It should just stay the same until inserted. Any
ideas? DO you guys want me to post all three pages of code?
lazerbrains555 Guest



Reply With Quote

