Passing a php variable to a form's hidden field

  • bgi
    Asked on May 25, 2014 at 2:40 PM

    Hi,

    I have a number of product pages on my site and want to put a contact form on each page but I'd like when the form is submitted for the product name to be passed from the page through to a hidden field on the form. Is this possible?

    Currently in the old PHP form that I want to replace, it says:

    input type="hidden" name="productname" value="item->name;?>

    Can this be embedded in some way in the jotform and/or does it matter which embed method I use (currently using Joomla embed with javascript)
    Warren
  • jonathan
    Replied on May 25, 2014 at 4:47 PM

    Hi Warren,

    You can use the form's Send Post Data feature to post submission data using PHP.

    Refer to this guide also -How-to-Post-Submission-Data-to-Thank-You-Page

    Passing a php variable to a forms hidden field  Image 1 Screenshot 20

     

    To find out the PHP codes and variable names, you can test submit your form first to https://www.jotform.com/show-post-data

    OR

    follow this guide -Getting-the-Variable-Names-and-PHP-code-in-Send-Post-Data-method

    Hope this help. Inform us if you need further assistance.

    Thanks!

     

     

  • bgi
    Replied on May 25, 2014 at 5:09 PM

    Thanks Jonathan,

    I'm using your Zoho integration to pass form data through to Zoho and that is why I need the product name in a field so that Zoho CRM knows which product has triggered the lead and so can assign it to the right person and trigger other events.

    I'm not sure I understand this Send Posts Data method completely but it doesn't seem to be the right thing to get the variable into the field that will then be available in the Zoho CRM integration field mapping.

    Warren

  • jonathan
    Replied on May 25, 2014 at 7:09 PM

    Hi Warren,

    It seems I overthink your requirement and misunderstood it instead. Sorry for that.

    BUT Yes, you can pre-populate a form hidden field also by using field URL parameter. 

    Check this user guide -Prepopulating-fields-to-your-JotForm-via-URL-parameters

    Test submit this form http://www.jotform.me/form/41447670804456?source=producttest

    In the submission, the hidden source field should have value of "producttest"

    What you also need to do first on your PHP product page is to assign the productname value to a variable so that you can use it in the JotFrm form URL.

    Something like this

    http://www.jotform.me/form/41445563619459?source={productname}

     

     Hope this help. Inform us if you need further assistance.

    Thanks!