A routine I'm developing for processing long forms:
// ** 1. DECLARATIONS
// DOCUMENT SHORTHAND
$_iPATH['root'] = realpath($_SERVER['DOCUMENT_ROOT']);
$_iPATH['super'] = dirname($_iPATH['root']);
// ** 2. CHECK FLAG TRIGGER
// ** 3. INSERT/UPDATE DB
// TABLE n : name
# prep data
# package data
# insert data
# verify
// ** 4. SEND MAIL NOTICES
// MAIL NOTICE
if ( $_FLAG['data_inserted'] )
{
# DEBUG
#trigger_notice('data inserted -> trying to send mail');
# set to: address
# set confirm URL
# set message
# send
}
// ** 5. GENERATE FEEDBACK
// ** 6. RESET DATA
// ** 7. REDIRECT