processformdata (custom processing function)

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.

Function parameter

The parameter passed to the function is an array indexed by field name, where each entry is a sub-array with these indexes:

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

Return value

Trying it out

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.