define(array("form" => "user_contact.tpl")); $possible_data = array("right" => "checkbox", "question" => "checkbox", "representation" => "checkbox", "name" => "text", "email" => "text", "street" => "text", "city" => "text", "state" => "text", "zip" => "text", "phone" => "text", "facsimile"=> "text", "comments" => "text" ); //posting if($submit['post']){ if (empty($data['name'])) $errors['name'] = 1; if (empty($data['phone'])) $errors['phone'] = 1; if(!check_email($data['email'])) $errors['email']=1; if (count($errors) == 0){ send_contact(); } } $tpl->assign("CONTACT_US_CMS", @file_get_contents("contact-us-cms.htm")); //data display display_data($data,$possible_data); //error display $possible_errors = array("name","email","phone"); display_error($errors,$possible_errors); $tpl->parse("HTML","main_head"); $tpl->FastPrint("HTML"); $tpl->parse("HTML","form"); $tpl->FastPrint("HTML"); $tpl->parse("HTML","main_foot"); $tpl->FastPrint("HTML"); } #------------------------------ #--------SEND CONTACT---------- #------------------------------ function send_contact() { global $tpl,$config; $data = &$_REQUEST['data']; //admin email data fields captions $data_captions = array( "name" => "Name", "email" => "Email Address", "street" => "Street Address", "city" => "City", "state" => "State", "zip" => "Zip", "phone" => "Telephone Number", "facsimile" => "Facsimile", "comments" => "Comments" ); $tpl->define(array("email_admin" => "email_contact_admin.tpl")); $tpl->define(array("email_user" => "email_contact_user.tpl")); $tpl->define_dynamic("field","email_admin"); $tpl->define_dynamic("right","email_admin"); $tpl->define_dynamic("question","email_admin"); $tpl->define_dynamic("representation","email_admin"); $tpl->assign("NAME",$data['name']); //assigning data reset ($data); foreach($data as $i => $content){ if (empty($content)) $data[$i]="Not submitted"; else{ //multi selects if(is_array($data[$i]) && count($data[$i])) $data[$i] = implode(", ",$data[$i]); } if($data_captions[$i]) { $caption = $data_captions[$i]; $tpl->assign(array( "FIELD_NAME" => "$caption", "FIELD_VALUE" => $data[$i] )); $tpl->parse("FIELD",".field"); } } if ($data['right'])$tpl->parse("RIGHT","right"); else $tpl->clear_dynamic("right"); if ($data['question'])$tpl->parse("QUESTION","question"); else $tpl->clear_dynamic("question"); if ($data['representation'])$tpl->parse("REPRESENTATION","representation"); else $tpl->clear_dynamic("representation"); $tpl->parse("HTML","email_admin"); $message_admin = $tpl->fetch("HTML"); $tpl->parse("HTML","email_user"); $message_user = $tpl->fetch("HTML"); // to admin. send_email($config['email_contact'],"Contact via Website",$message_admin,$data['email'],""); // to user send_email($data['email'],"Contact @ $config[website_name]",$message_user,$config['email_contact'],""); redirect("contact.php?action=landing","Message sent... Reload",0,""); } #------------------------------ #----------CONTACT_LANDING----- #------------------------------ function contact_landing() { global $tpl,$config; $tpl->define(array("form" => "user_contact_landing.tpl")); $tpl->parse("HTML","main_head"); $tpl->FastPrint("HTML"); $tpl->parse("HTML","form"); $tpl->FastPrint("HTML"); $tpl->parse("HTML","main_foot"); $tpl->FastPrint("HTML"); } //STARTS HERE--------------------------------------------------------------- $action_prefix = "contact_"; $action_default = "form"; include_once("prepare_script.php"); eval($action_prefix . $action . "();"); ?>