rendered paste bodyif (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<br>\n";
}
if ($email==NULL || is_email($email)==0 ){
$toggle = $toggle-1;
echo "You have not entered in the correct email<br>\n";
echo "<br>";
}
if ($comments==NULL){
$toggle = $toggle-1;
echo "You did not input any comments please go back<br>\n";
}
//if everything not okay
if ($toggle != $perfect){
show_contact_form();
}
else {
echo "Your mail has been sent!<br><br>";
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 "<form name=\"form1\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n";
echo "<table width=\"335\" height=\"287\" border=\"0\">\n";
echo "<tr>\n";
echo "<td width=\"65\" height=\"40\">Name</td>\n";
echo "<td width=\"260\"><input name=\"name\" type=\"text\" size=\"40\" /></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td width=\"65\" height=\"40\">Email</td>\n";
echo "<td width=\"260\"><input name=\"email\" type=\"text\" size=\"40\" /></td>\n";
echo "</tr>\n";
echo "<tr valign=\"top\">\n";
echo "<td width=\"65\" height=\"177\">Comments</td>\n";
echo "<td width=\"260\"><textarea name=\"comments\" cols=\"40\" rows=\"13\"></textarea></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td height=\"26\"> </td>\n";
echo "<td><input type=\"submit\" name=\"Submit\" value=\"Submit\" /></td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "</form>\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);
}
?>