As site owner (or developer), you can include custom PHP on your contact page before the call to twzContact. If a function named processformdata exists, twzContact will call it after succcessful submission of the form, but before the email is sent.
The idea is that the processformdata function can save the user-submitted data to a file or database, and/or send emails to the owner and/or visitor - either in addition to, or instead of the default twzContact email.
If you want to perform custom checks on the data submitted by the user, use preprocessformdata instead.
processformdata() must accept one parameter (array of fields), and return either a boolean or string result.
The parameter passed to the function is an array indexed by field name, where each entry is a sub-array with these indexes:
DateFormat
email optionNote that if you change the contents of the parameter variable inside the function, this will have NO EFFECT on the email or any logging performed by twzContact.
If processformdata() returns a string, the string can be included in the EmailStart
, EmailExtra
or Subject
email options by using a %process_result% placeholder.
For example, in your settings file:
[Email options] ToAddress = formtest@yourdomain.com Subject = Message #%process_result% from your web site EmailExtra = Go to http://yourdomain.com/view.php?id=%process_result%
Of course the "string" could actually be a number, eg "323".
If processformdata() returns a boolean FALSE, the default twzContact email won't be sent and no log will be written (so your processformdata function MUST do something useful with the submitted data or there's no point!)
The easiest way to understand what's going on here is to use something like the following as your include text:
<?php function processformdata($Fields) { echo 'Data submitted:<pre>'; print_r($Fields); echo '</pre>'; return false; } define('INI_FILE', '../path.to.ini.file'); require_once('twzContact.php'); ?>
This will show your contact form as usual, but when you submit the form (without errors), the submitted data will be shown on the screen and no email will be sent.