We are very familiar with the feature in Prepopulating the fields to your Jotform via URL Parameters wherein the form always receives 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 HTTP 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 a Jotform form into your own website or PHP script, provides a lot of flexibility in collecting data and as well as enhancing user’s experience since you are using your own custom web pages with JotForm.
This tutorial will show how to send submission data via the HTTP POST method and using the Thank You Page. This Jotform feature uses the POST request method which requires PHP.
The tutorial is divided into 2 parts:
Creating the Form
Log in to Jotform and create a form using the Form Builder. When you’re satisfied with the form…
Enable the Send Post Data
- Go to Settings.
- Hit the Show More Options button.
- Scroll down and set the Send Post Data option to Yes.
Redirect the Thank You Page
Use the Thank You Page wizard to add the URL address of the target PHP script.
To set this up, go to Settings » Thank You Page » Redirect to an external link after submission. Then input your PHP script’s address in the Enter URL field.
The URL address should be the PHP page that exists on your website.
Creating the Custom PHP Page
The URL entered in the Thank You Page wizard’s “Redirect to an external link after submission” should be able to handle the HTTP POST request.
- Start creating your PHP web page using your editor (any text editor will do).
- For the purpose of this tutorial, copy and paste the following code into your text editor:
<?php print_r($_POST); ?>
- 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.
- Make sure it is deployed and located in your website with the same address as what you provided in the Thank You Page’s Enter URL field. For example, the URL address provided in the form’s Thank You page in my case is https://www.jotform.com/redirect.php
To use the data from the HTTP POST request, you need to know the correct keys of the $_POST variable. You can get the keys by following this guide: How to Post Submission Data to Thank You Page
An example is this Send POST Data form. The PHP code or $_POST variables for my fields are as follow:
Now in your PHP script, you can simply use those variables to process the data and use it as your own.
It is quite necessary that you have knowledge of PHP to fully utilize and implement this. I suggest checking the links below to help you get started.
Cases where you can implement this tutorial:
- 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
- You want to pass data to another page or script, but you don’t want it to be populated in the URL itself.
- 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 on our forum page.
Do you want to make a PHP form? Please have a look at the page referred to.