Carrying a variable through 3 page form

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

  6. #5

    Default 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

  7. #6

    Default 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

  8. #7

    Default 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

  9. #8

    Default 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

  10. #9

    Default 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

  11. #10

    Default 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

  12. #11

    Default 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

  13. #12

    Default 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

  14. #13

    Default 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

  15. #14

    Default 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

  16. #15

    Default 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

  17. #16

    Default 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

  18. #17

    Default 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

  19. #18

    Default 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

  20. #19

    Default 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

  21. #20

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139