require( "admin/config.inc.php" );
include("/usr/local/lib/php/spam_check.php");
// define the templates for general layout and the page content
$tpl->define(array(
"common" => "common.tpl.html",
"body" => "contact.tpl.html",
"sent" => "contact_sent.tpl.html"
));
// assign initial values
$tpl->assign(array(
"TOP_NAVIGATION" => "Home :: Contact Us"
));
if( !$submit ){ // display the contact form
$tpl->assign(array(
"FORM_ACTION" => $PHP_SELF
));
$tpl->parse( "BODY", "body" );
}
else{ // form submitted
spam_check($_SERVER["SERVER_NAME"]);
// check if the fields were filled, and build the error message
$errMsg = '';
if( trim($contact_name) == '' ) $errMsg .= '
Name';
if( trim($contact_address) == '' ) $errMsg .= 'Address';
if( trim($contact_city) == '' ) $errMsg .= 'City';
if( trim($contact_state) == '' ) $errMsg .= 'State';
if( trim($contact_zip) == '' ) $errMsg .= 'Zip';
if( trim($contact_email) == '' ) $errMsg .= 'E-mail';
if( trim($contact_phone) == '' ) $errMsg .= 'Telephone';
if( trim($contact_memo) == '' ) $errMsg .= 'Comments';
if( strlen($errMsg) != '' ){
// we have unfilled fields => display error message at top, and show the form again
$tpl->assign(array(
"ERR_MSG" => "Please fill the field(s) listed below: ",
"FORM_ACTION" => $PHP_SELF,
"CONTACT_NAME" => stripslashes( $contact_name ),
"CONTACT_ADDRESS" => stripslashes( $contact_address ),
"CONTACT_CITY" => stripslashes( $contact_city ),
"CONTACT_STATE" => stripslashes( $contact_state ),
"CONTACT_ZIP" => stripslashes( $contact_zip ),
"CONTACT_EMAIL" => stripslashes( $contact_email ),
"CONTACT_PHONE" => stripslashes( $contact_phone ),
"CONTACT_MEMO" => stripslashes($contact_memo)
));
$tpl->parse( "BODY", "body" );
}
else{
// all the required fields were filled, send the mails
$sendText = "
Name: " . stripslashes( $contact_name ) . "
Address: " . stripslashes( $contact_address ) . "
City: " . stripslashes( $contact_city ) . "
State: " . stripslashes( $contact_state ) . "
Zip: " . stripslashes( $contact_zip ) . "
E-mail: " . stripslashes( $contact_email ) . "
Telephone: " . stripslashes( $contact_phone ) . "
Comments/Questions: \n\n " . stripslashes($contact_memo);
// send mails
$fromField = stripslashes( "$contact_name <$contact_email>" );
mail( $mailto, "webuilderinc.com Contact form", $sendText, "From: $fromField" );
mail( $mailto_admin, "webuilderinc.com Contact form", $sendText, "From: $fromField" );
$tpl->parse( "BODY", "sent" );
}
}
// parse the contents and generate the web page
$tpl->parse( "MAIN", "common" );
$tpl->FastPrint();
?>