Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryOur Software in Action >  >Master Form V4 in Action

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Master Form V4 and Custom Thank-You Pages

When Master Form V4 processes a form, the thank-you page may be customized.

After the form is submitted, Master Form V4 grabs a template file and customizes it. It then displays the file from within itself. The URL in the browser window is the URL of the MasterFormV4.cgi script.

A note: The "customized thank-you page" feature hides the actual location of the thank-you page. If the MasterFormV4.cgi script is loaded directly into the browser instead of going through the form, the thank-you page is unavailable.

Sometimes, however, it is desirable to have the URL of the customized thank-you page in the browser's address bar, not the URL of MasterFormV4.cgi. That can be done if the thank-you page is a PHP page.

In the form, the hidden field name="redirect" value contains the location of the thank-you page — plus some information parameters. I'll show you how to do it.

Lets suppose the thank-you page will be customized with the name and the email address provided on the form. First, we set up the form, then the thank-you page.

Here is a form.

<form 
   method="POST" 
   action="/cgi-bin/mf/MasterFormV4.cgi">
<input 
   type="hidden" 
   name="redirect" 
   value="http://example.com/thankyou.php?fn=[[firstName]]&email=[[email]]">

First Name: 
   <input type="text" name="firstName" size="20"><br />
Email: 
   <input type="text" name="email" size="20"><br />
<input type="submit" value="GO"></td>

</form>

The parameters of the thank-you page URL start with the question mark following thankyou.php —
?fn=[[firstName]]&email=[[email]]

The two placeholders, [[firstName]] and [[email]], contain the names of the respective form fields. After the form is submitted, the placeholders will be replaced with the information provided in those fields.

Let's suppose the name is typed in as "Leroy" and the email address as "name@example.com". The actual redirect URL then becomes

http://example.com/thankyou.php?fn=Leroy&email=name@example.com

When the browser arrives at the thankyou.php page, parameter name "fn" contains value "Leroy" and parameter name "email" contains value "name@example.com". PHP on the page extracts those values and customizes the page with them.

Here is what the PHP page might look like.

<html>
<body>

<p>

<?php
if( ! empty($_GET['fn']) ) { echo $_GET['fn'].', '; }
else { echo 'Friend, '; }
?>

thank you for using our form.

<?php
if( ! empty($_GET['email']) ) { echo 'An email has been sent to '.$_GET['email'].'.'; }
?>

</p>

</body>
</html>

In the above page, the first set of PHP code (4 lines) prints either the value of parameter name fn or it prints the name as Friend. Following either of those, is a comma and a space.

The page then prints, "thank you for using our form."

The second set of PHP code (3 lines) prints the "An email has been sent to " and the value of parameter email — if parameter email contains a value. Otherwise, nothing is printed.

Using our example, the page publishes, "Leroy, thank you for using our form. An email has been sent to name@example.com."

The result is a customized thank-you page with the URL of the thank-you page in the browser's address bar.

For other customization, substitute the example placeholders with placeholders of your own. And make corresponding edits on the PHP thank-you page.

Will Bontrager

Was this article helpful to you?
(anonymous form)

All information in WillMaster Library articles is presented AS-IS.

Support Area – Ask Your Question Here

The "Code in articles help" forum at the Willmaster.com support area is the place to get information about implementing JavaScript and other software code found on Willmaster.com

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

Need Custom Software?
Click to
tell us about
your project.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC