This form demonstrates the 'reflexive' use of gk_formmail.php. In 'reflexive' mode, a single php form does all the work: accepts user input; validates the input; sends email containing data collected; displays error or success messages to the user. This is recommended over 'static' mode, which requires multiple html pages to do the same work, since: 1) fewer pages need to be maintained, 2) though equally secure as reflexive mode, in most respects, users can view the source of html pages but cannot view the source of php pages, which ensures that you will never accidentally expose private information in your forms.

gk_formmail.php requires that each form has an associated configuration file, named in relation to the form file. In this case, the form file is 'reflexive.php' so the related config file must be named 'reflexive.php.config.php.'

We've included sample fields to show you how to submit Checkboxes, Radio Buttons, Multi-selection List Boxes, normail Text fields, and Text Areas.

Actual sending of email has been disabled in the demo form below. Instead, we simply display the collected data from the form (with minimal formatting) that would normally be sent by email.

-- Form Results:


Please enter your name:

Please enter your email address:

May we contact you?

Yes No

What are your favourite colours?

Red Blue Yellow

What vehicles do you have a license to operate?

 (CTRL-click to select multiple items)

Please enter your message:


Brief Analysis - detailed documentation of script operation is included in the comments inside gk_formmail.php master controlling script.

This demo shows how to:
1. maintain the state of form inputs
2. handle errors interactively
3. display a 'success' message when done

Note that there is no need for redirection to separate error / success pages (though optional use of tectite 'good_url' and 'bad_url' redirection still works).

This file initially includes the gk_formmail.php script, which processes form input and sets some global variables that can then be used within your form page to customize the display of messages to the user.

This is all done without the need for any PHP logic embedded in the form HTML, thus satisfying one of the cardinal rules of good design: separation of logic from formatting!

This is possible by simply echoing the values of functions provided by gk_formmail.php, whose output is determined dynamically.

For example, echoing the output of a function such as FormResult() will display the correct output to the user, depending on the current state of the form:
* Nothing - the first time the page is loaded.
* An error message - if the form inputs fail any validation tests.
* A success message - if all form inputs passed the validation tests and submission was successful.

There are three files required (click links to view source):
+ the HTML form: reflexive.php
+ a config file: reflexive.php.config.php
+ gk_formmail.php (available for licensing): the master 'controlling' script.

Each form has an associated configuration file, named in relation to the 'action' handler for the form: [action].config.php
In this case, the form is its own 'action' so the name of the config file is directly related to this file: reflexive.php.config.php
Alternately, you could allow multiple pages to share the same form 'action' file, and the same configuration file, without the need for redundant configuration within the several HTML forms (as would be required by tectite formmail).

Below is some debugging output that reflects the current state of some of the PHP variables available to this form.
The default values of FormErrorText and FormSuccessText were configured in the associated config file.


FormResultText()=Thank You!

$OUTPUT_VALUES['FormErrorText']=Form Errors

$OUTPUT_VALUES['FormErrorItemList']=

$OUTPUT_VALUES['FormSuccessText']=Thank You!

$OUTPUT_VALUES['FormResults']=

$OUTPUT_VALUES=

Array ( [FormOutput] => [FormErrorText] => Form Errors [FormErrorItemList] => [FormError] => [FormErrorInfo] => [FormErrorCode] => [FormErrorItems] => [FormIsUserError] => [FormAlerted] => [FormSuccess] => Success [FormSuccessText] => Thank You! )


This is a modified version of tectite formmail and many requirements have been changed.
For more information, see comments inside gk_formmail.php
For more information about tectite formmail, visit www.tectite.com