if (isset($_POST['Submit'])){ $pefect = 3; $toggle = 3; //validate $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; if ($name==NULL){ $toggle = $toggle-1; echo "You did not input your name
\n"; } if ($email==NULL || is_email($email)==0 ){ $toggle = $toggle-1; echo "You have not entered in the correct email
\n"; echo "
"; } if ($comments==NULL){ $toggle = $toggle-1; echo "You did not input any comments please go back
\n"; } //if everything not okay if ($toggle != $perfect){ show_contact_form(); } else { echo "Your mail has been sent!

"; send_htmlmail($email,$name,$comments); } } else { //this is to make sure people dont submit things twice show_contact_form(); } include ("template/template_end.php"); function show_contact_form(){ echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Name
Email
Comments
 
\n"; echo "
\n"; } function is_email($Addr){ $p = '/^[a-z0-9!#$%&*+-=?^_`{|}~]+(\.[a-z0-9!#$%&*+-=?^_`{|}~]+)*'; $p.= '@([-a-z0-9]+\.)+([a-z]{2,3}'; $p.= '|info|arpa|aero|coop|name|museum)$/ix'; return preg_match($p, $Addr); } function send_htmlmail($e,$n,$c){ $to = $SETTINGSVAR_contactmail; $subject = "Comments from". $n. " of ".$e." Auto Answer site"; $message = strip_tags($c); $headers = "From: ".$e."\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // Send mail($to, $subject, $message, $headers); } ?>