setError(checkRequired($post,$required)); if(!empty($post['email'])){ if(!is_email($post['email'])) $errors->setError('Email is invalid format.'); } $validate_phone = str_replace('-',NULL,$post['phone']); if(strlen($validate_phone) < 10 || !is_numeric($validate_phone)) $errors->setError('Please enter a valid phone number.'); if(!empty($post['security_code'])){ if($post['security_code'] != $_SESSION['code']) $errors->setError('You have entered an invalid security code.'); } $error = $errors->getError(); if(!$error){ $post['ip'] = $_SERVER['REMOTE_ADDR']; $mail = new main; $mail->Template('sendmail'); $mail->Parameter('name',SITE_NAME.' Admin'); $data_fields_array = array('name','email','phone','comments','ip'); $data_fields = NULL; $data = $post; foreach($data_fields_array as $key){ if(!empty($data[$key])) $data_fields .= ''.replaceChar('_',' ',$key).':'.(($key == 'comments') ? cleanHTML($data[$key]) : $data[$key]).''; } $mail->Parameter('body','A user has submitted a request or comments using the contact us form. Here is the details of the request.

'.$data_fields.'
'); $mail->Parameter('site_url',SITE_URL); $mail->Parameter('site_url_display',SITE_URL_DISPLAY); $mail->Parameter('site_name',SITE_NAME); $msg = $mail->Display(); sendemail(SITE_ALIAS,NO_REPLY_EMAIL,SITE_EMAIL,SITE_NAME.' - Contact Us',$msg,NULL,notifyOtherAdmins('request_form')); $post['status'] = 1; $post['date_added'] = 'NOW()'; insertRecords('tContactUs',getMysqlTableFields('contact_us',$post)); header('Location: thank-you.html?name='.urlencode($post['name'])); exit; } } $class = new main; $class->Template('main'); $class->Parameter('stylesheets',NULL); $class->Parameter('javascripts',NULL); $class->Parameter('random-testimonial',displayRandomTestimonialMain()); $class->Parameter('contents',displayTemplate('contact_us')); $fields = array('name','email','phone_1','phone_2','phone_3','comments'); foreach($fields as $sKey) $class->Parameter($sKey,$post[$sKey]); $class->Parameter('code',''); $class->Parameter('error',($error) ? ''.$error.'' : NULL); displayOtherTags($class); echo $class->Display(); include('footer.php'); /**************** private functions ***********/ ?>