gk_formmail.php is a very flexible HTML form processing script based on tectite formmail.
Below are some sample forms (without any email recipients configured) illustrating a couple of ways gk_formmail.php can be deployed:
1. 'Static' mode, using a static HTML form and several auxiliary files:
static.htm
2. 'Reflexive' mode, using a dynamic PHP form and a single auxiliary config file:
reflexive.php
The major differences between gk_formmail.php and the original tectite formmail are listed below.
+ All configuration options have been removed from the HTML forms.
gk_formmail.php requires configuration by means of PHP config files (one for each form), located in the same directory as the form [action] script, named in relation to the [action] script as follows:
[action].config.php
+ gk_formmail.php offers enhanced security.
Tectite formmail tries very hard to work around a basic design flaw: it is configured from the HTML forms themselves, thus leaving configuration open to attack or abuse, 'harvesting' of email addresses for spamming, etc.
+ gk_formmail.php separates business logic from presentation.
Tectite formmail leaves most configuration logic in the HTML domain, including things such as regular expressions for field validation that should be exclusively in the domain of PHP programmers rather than HTML editors. This change of design also makes such logic off limits to hackers who could easily circumvent form validation.
+ gk_formmail.php separates individual form configuration from core gk_formmail.php logic, shared by all forms.
Only one copy of gk_formmail.php should exist on a server, thus making bug fixes and upgrades global.
Tectite formmail requires different configurations to use separate copies of the entire formmail.php script, resulting in a potential maintenance nightmare.
+ gk_formmail.php offers optional suppression of all output in 'quiet mode' and 'reflexive mode', allowing self-validating (aka 'reflexive') forms instead of more complex multi-file redirection or the use of direct output from script, with all formatting predetermined.
Tectite formmail typically redirects to 'error page' or 'thank you page' whereas gk_formmail offers the simplicity of a single form script (reflexive.php) which functions in various modes, via use of global variables containing error message and other info, thus avoiding problems of Tectite formmail in maintaining state between redirected pages.
+ gk_formmail.php offers global auto-validation for email or other fields, from within the gk_formmail.php script, avoiding the need for complex regular expressions embedded in each form's configuration, as is the case with tectite formmail.
+ gk_formmail.php improves organization of programming style.
All function definitions are in a separate file. Tectite formmail scatters function definitions throughout main code logic, resulting in difficult maintenance and debugging.
+ gk_formmail.php provides global variables and functions that can be configured for display of common error or success messages and for easily maintaining state of form inputs. The functions, such as FormResults(), which apply formatting to plain text output, can be overridden by your own custom functions, if desired, since these are defined in PHP using: if (!function_exists('FormResults')) { ... }.
+ gk_formmail.php automatically applies CSS class attributes to the text output from FormResult().
You can give them definitions as follows:
<style type="text/css">
*.FormResultSuccess {color: green;}
*.FormResultError {color: red;}
</style>
If you prefer, inline styles can be used by passing them as parameters:
FormResult("color: green;", "color: red;")