Send Submission Data via POST Method Using PHP and the Thank You Settings

Last Update: November 10, 2016

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: You can simply send the data via the URL parameter as mentioned in the link first shared above, you can also check this link to a guide that allows you to send data to another URL by prepopulating the target URL parameter from the form fields of form #1.

Example b: We want to send the form field data to a target PHP script via POST method, this will NOT append the data in the URL parameter, which makes this method more secure. 

Being able to directly send the information from JotForm form into your own website or PHP script, 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 submission data via POST method and using the "Thank You" settings.

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 Preferences.

Navigate to "Advanced" tab and click "Show More".

Here, enable the "Send POST Data", select "Yes" in the drop down option.

 

Click the "Save Changes" button.

3. When satisfied with the form, use the "Thank You" Wizard to add the URL address of the target PHP script. First, click on the Thank You button.

 

4. Click on "Redirect to external link" and paste the path of your PHP script there.

 

 

5. Click the "Save Changes" button to apply the changes made.

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 URL entered in the "Thank You" wizard's redirect to external link should be able to fetch PHP tags.

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 or you can name it anything that you like, it should at least have an extension of .php as a file.

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

Example: The URL address provided in the form's Thank You page in my case is:  

http://www.mysite.com/redirect.php 

 

5. To fetch the data from the POST method. You need to know the correct PHP tags of your forms. You can get your fields PHP code by following this guide: https://www.jotform.com/help/51-How-to-Post-Submission-Data-to-Thank-You-Page 

Example is this form: https://form.jotform.com/63143715707960. The PHP code or tags for my fields are listed which are the following:

PHP Code:

$_POST['submission_id'];

$_POST['formID'];

$_POST['ip'];

$_POST['name']['0'];$_POST['name']['1'];

$_POST['email'];

$_POST['message'];

 

Now in your PHP script, you can simply use those to fetch the data and use it as your own. 

 

Important: It is quite necessary that you have knowledge with PHP on this case to fully utilize and implement this. I suggest checking the links below to help you get started.

What is PHP by PHP.net 

PHP Tutorials by W3Schools 

PHP Forms Explained 


Cases where you can implement this tutorial:

1. You want to save the information submitted directly on your database. There's a specific guide about this here: How to send submission data to your MySQL database using POST method and PHP 

2. You want to pass data to another page or script but you don't want it to be populated in the URL itself. 

3. Pass data to a 3rd party application that accepts POST data. 

 

I hope that helps. Feel free to comment below if you have questions or concerns, or you can also open a new thread in our forum page.


15 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


   
Sharifuddin (October 01, 2016 at 05:02 PM)

Finally figured how to get POST with array-type

$first = $_POST[fullname3][first];
$last = $_POST[fullname3][last];

View Answer


   
FFS_user (November 04, 2016 at 11:49 PM)

Great tutorial but something's not quite working right.

We've embedded two jotforms on our wordpress site. Form 1 needs to pass the email and name fields to form 2. The email field is posting fine but the name field is not.

In my redirect.php file, if I use the name fields like they are in the tutorial -

$var1 = "?fullName[first]=".urlencode($answers[fullname][0]);
$var2 = "&fullName[last]=".urlencode($answers[fullname][1]);

- then the name doesn't pass to form 2. It's just blank.

But if I change it to this -

$var1 = "?name[first]=".urlencode($answers[name][0]);
$var2 = "&name[last]=".urlencode($answers[name][1]);

then the name passes fine to the form but gives this error:

Warning: trim() expects parameter 1 to be string, array given in /XXX/XXX/wp-includes/query.php on line 1609

Not sure what I'm doing wrong. Perhaps it's a conflict with wordpress files. Any ideas?

Form 1 is here:
http://tinyurl.com/gtbqzj4
(which references this form https://form.jotform.com/62437535188160)

It redirects to form 2 here:
http://tinyurl.com/hh8fhop
(which refrences this form https://form.jotform.com/63063550543148)

Thanks for any help.

View Answer


Send Comment