PHP 101: Gravity Forms, Query Strings & Conditional Content on Confirmation Pages

On PMC, I wanted to set up a confirmation page that a user would be redirected to after filling out a form. I wanted this confirmation page to display content associated with the form the user had just filled out.

Maybe I am behind times, but I never really wrapped my head around parsing query strings before and I had some fun figuring it out.

FYI: You can pick a confirmation page from the Gravity Forms editor and create a query string populated with content from the form. Word to the wise, if you have “pretty labels” for your forms, ex: “Your Name”, you’ll want to enter an admin label for this field without any spaces, otherwise query string breaks redirect.

To get current page URL:

$pageURL = 'http';

 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 } else {
 return $pageURL;

To print the resulting array:

$pageUrl = parse_url(curPageURL());

To access query string:

$pageUrl['query'];   (duh - c'mon guys)

Let’s say your query string looks something like this:


To parse it and echo contents as variables:

$str = $pageUrl['query'];
echo $form;
echo $email;

Some Extra Tidbits

$_GET[‘form’] and $_GET[’email’] will also be available in the page as well, as those are global variables that get set by the server before PHP begins.

Protip to avoid PHP warnings/notices: before relying on a variable in any array ($_GET, $_POST, array(‘foo’ => ‘bar’), etc.) it’s best to check the presence of it before trying to output it.


if ( isset( $_GET[‘form’] ) ) {
echo $_GET[‘form’];