Send POST Data From JotForm Using PHP in Custom Thank You Page

Last Update: October 28, 2015

We are very familiar of the feature in Prepopulating the fields to your JotForm via URL Parameters wherein the form always receive the parameter data. With this feature, form fields are automatically given default values when a URL address to the form with included parameters is clicked.

What if you wanted to send the parameter data instead? And the target page is not a JotForm form?

Example a: This Form #1 is able to send parameter data to Form #2

Example b: This Form #1 is able to send parameter data to another HTML page. 

Being able to directly send the information from JotForm form into your own website, provides a lot of flexibility in collecting data and as well as enhancing user's experienced since you are using your own custom web pages with JotForm.

This tutorial will show how to send parameters from JotForm using a custom Thank you page.
This JotForm feature uses the POST request method which requires PHP scripts.

PHP is required to be supported and enabled on the web server of the custom page.

The tutorial is divided into 2 parts.

Part 1 : Creating the Forms
Part 2 : Creating the custom PHP page

=====================================================================

Part 1 - Creating the form:

1. Login to JotForm and create the form in the form builder.

2. To complete the form, enable the Send Post Data feature of the form.

Click on Setup & Embed > Preferences > Advance Settings > Send Post Data (make sure the value is Yes


Click on the Close Settings button to save and close the wizard.

3. When satisfied with the form, use the Thank You Page Wizard to to add the URL address to the custom page. 
Click on Setup & Embed > Thank You


4. Click on REDIRECT TO PAGE.


5. In the Thank You Page Redirect URL dialog box, put the full URL address of the custom page and click on APPLY to save the changes



Note : The URL address should be the PHP page that exists in your website (this is the page created in Part #2 of this tutorial)

6. Click Finish to save and close the wizard.

7. Save the Form.

8. Preview and Test the form.


Part 2 - Creating the Custom PHP Page

The JotForm Thank You Page Redirect URL target can be another Form or a Custom Web Page.

1. Start creating your PHP web page using your editor (any text editor will do)

2. For the purpose of this tutorial, follow or copy the describe PHP scripts found on this guide.

3. Save the PHP page as redirect.php

4. Make sure it is deployed and located in your website with the correct URL address that was similarly used in
  Step #5 in the Part 1 of this tutorial.

i.e. : The URL address provided in the form's Thank You page is  
http://www.mysite.com/redirect.php


The 2 sets of PHP codes below demonstrate and shows the correct code between sending to a form or to a custom web page.


Send Data to another JotForm form:

$answers = $_POST;
$url1 = "http://jotformpro.com/form/23503595638965"; // This is the URL address of the Form

$var1 = "?fullName3[first]=".urlencode($answers[fullname3][0]);
$var2 = "&fullName3[last]=".urlencode($answers[fullname3][1]);
$var3 = "&email4=".urlencode($answers[email4]);
$var4 = "&comments=".urldecode($answers[comments]);
$url2 = $url1.$var1.$var2.$var3.$var4;
header("location:$url2");
?>

You can also take this source code here: http://pastiebin.com/52646417a1a14


Send Data to another web page:

$answers = $_POST;
$url1 = "http://www.mysite.com/custompage.html"; // This is the URL address of the custom web page

$var1 = "?fullName3[first]=".urlencode($answers[fullname3][0]);
$var2 = "&fullName3[last]=".urlencode($answers[fullname3][1]);
$var3 = "&email4=".urlencode($answers[email4]);
$var4 = "&comments=".urldecode($answers[comments]);
$url2 = $url1.$var1.$var2.$var3.$var4;
header("location:$url2");
?>

You can also get a copy of this source code here: http://pastiebin.com/526464f6f2267

===================================================================
Explanation of the basics of the PHP codes in this tutorial. 

*** It is necessary to have a minimum programming knowledge to be able to understand the procedures describe in the PHP codes of this tutorial.

The variable $answers will be the array container when http $_POST method is passed.

$url1, url2 are variable use for the target URL address. 

$var1, var2, var3, var4 are the declared variables that will contains the data from the required fields from the form. In the tutorial, the fields are fullname(first,last), email, and comments.

header(location:) is a PHP function that will send a raw HTTP header into the web page. In this tutorial, the header function specify the URI of the target form or custom page to be able to pass the parameter data.

i.e. the resulting URL address of the target form/page is like this 
---
http://www.mysite.com/custompage.html?fullName3[first]=jonathan&fullName3[last]=jotform&email4=jonathan%40jotform.com
&comments=This%20is%20a%20test%20comments
--- 
.urlencode removes the % characters in the raw data when passed via URL parameters 

.urldecode replaces the + characters with an actual space character in the raw data when passed. This is used in the comments field value.

 ===================================================================

5. Preview and Test the form. 

When the form is submitted it will be redirected to the redirect.php page and the PHP scripts will passed the parameter data into the 2nd form or the custom page.

Here are the demo of the working forms using this guide. Fill in the forms and submit to able to view the results.



14 Comments...


   
jklupfel (March 05, 2013 at 01:15 AM)

in the php code examples you need to add

View Answer


   
lastfrontierheli (May 02, 2013 at 01:29 PM)

Hi,

Could you please explain "$var1 = "?fullName3[first]=".urlencode($answers[fullname3][0]);"

Is "fullName3[first]" the id of the initial form and "[fullname3][0]" the ID of the the field in the second form that should be pre-populated?

My first form has the First name and Last name as simple text fields, and the second form (that I want populated with the names from the first form) has them in the "Full Name" format, could this be causing an issue? (I have the email pre-populating fine, but the names are not. If I understood what is being referenced by the redirect.php code (is it the field ID, name etc) I would be able to figure out my issue.

Any help would be greatly appreciated!

View Answer


   
aytekin (May 10, 2013 at 09:32 AM)

To find out the variable names and PHP code, simply set this URL as your Thank You URL, enable Send Post Data, fill your form and submit.

http://www.jotform.com/show-post-data


   
markashton (July 05, 2013 at 07:48 AM)

Hi,
I've just tested this and both form examples lead to a jotform.
Unless I'm mistaken none of these examples lead to a custom Thankyou Page. I would like to see a standard Thankyou page .. not one where there are form fields.
The reason I ask is because I cannot get this technique to pass the values into a standard Thankyou page on another domain.
Try it ... do any examples lead to a typical Thanksyou page?
Regards Mark
Thanks

View Answer


   
sbohler (August 04, 2013 at 05:14 PM)

Ahhhhh... I think you just opened up my world.

I want to perform financial and other calculations based upon selections within a jotform and have my calculated values passed to PayPal by the PayPal Pro Wizard section of a jotform.

Based upon this article and not knowing how to perform calculations within jotform itself, it seems my approach should be:

1 - Collect what I need via jotform A

2 - Pass this data via POST to a custom php page on my site named "redirect.php" (or whatever), who's URL I place in jotform A's custom Thank You page setting.

3 - Perform my financial and other calculations within my redirect.php file which passes it's results to jotform B who's PayPal Pro Wizard fields are thus prepopulated with my values.

The user will see my the calculated values in their proper fields, fill in their credit card info and proceed normally. The user will experience a simple transition from A)making selections, to B) verification and payment.

Is this the proper approach you would recommend for my needs?

View Answer


   
Emotion (October 08, 2013 at 08:02 PM)

thanks guys it helps a lot....


   
Galena Ojiem (March 20, 2014 at 02:10 PM)

I want to create a survey that asks several simple questions and then directs the user to a website with database results displayed based on their answers to all of the questions. For example, the answer string might be "producer, 25k, rural, Saturday." Depending on the entire string they would be directed to a website with a code for the database results which relate to that exact list which I will have already set up like so:[pdb_list filter="type=producer&amount=25k&location=rural&day=saturday"]. Is it possible to do this with JotForm?

View Answer


   
lafototeca (July 18, 2014 at 08:34 PM)

Hello.

Fine tutorial, thank you.

How can I work with a checkbox if I want to pass the result to the variable 5?

Can you help me with this?

Thank you.

View Answer


   
PEvaluations (February 15, 2015 at 12:36 PM)

If a form has a file upload (e.g. a photo) POST does not seem to include the URL to the file, just the name (e.g. photo.png). Is the submission ID available in the POST also? Perhaps that way I can use the API to pull the photo URL.

View Answer


   
capitalresorts (March 19, 2015 at 04:14 PM)

Hi, is it possible to use a form field (let's say "Member ID") and have that generate a custom URL through the PHP script with that Member ID in it? For example, the url would be: www.example.com/memberid=MEMBERID where MEMBERID would be the six-digit member ID that they input on the form.

Is it possible to accomplish this in the $url1 parameter?

View Answer


   
ergunersan (June 08, 2015 at 03:08 AM)

Hello, I want to pay with virtual POS, but not the project I'll use PHP ASP.NET MVC 3 Project. How we were able to integrate jotform with my project. Like php ASP.NET could you send the data to the project. thanks.

View Answer


   
nickbh (November 05, 2015 at 05:56 AM)

When the data is submitted using this method a "preloader" graphic is displayed before reaching the custom thankyou page.

Is it possible to remove the pre-loader or change the pre loader style?

Thanks

View Answer


   
Domingowell (April 17, 2016 at 06:55 AM)

Howdy! finasteride good site.

View Answer


   
Williamcic (October 01, 2016 at 09:30 AM)

Wide-format Inkjet: Many Communities, One Process office accesories children's book publishers The University of Tokyo researchers found that adding magnetized nanoparticles can help you “draw” dark lines for the surface from the display with a magnetized stylus that flips the black side in the microparticles up. The image stays there until an electric charge is put on clear the display. ,Death of Milton Friedman, Economic Roundup, and A $100 Laptop
250 MB Zip, 48x16 DVD-ROM ,office stationary 锘?a href="http://printing-in-china.com">book printing
printing-in-china.com


Send Comment