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