<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<div id="container">
<div id="wrapper">
<div id="main-content">
<?php
if(isset($_POST['submit'])) {
$to = "somebody@calvarybucyrus.org";
$subject = $_POST['subject'];
$name= $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$number= $_POST['number']; //security
$body = "$message";
$continue = "/";
// email validation
$error_msg='';
if(trim($name)==
'') {$error_msg.=
"Please enter your Name and/or Surname !<br>";
} if(trim($subject)==
'') {$error_msg.=
"Please enter a subject title !<br>";
}
if(trim($email)==
'') {$error_msg.=
"Please enter an email!<br>";
} else {
// check if email is a valid address in this format username@domain.com
if(!
ereg("[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]",
$email)) {$error_msg.="Please enter a valid email address<br>";}
}
if(trim($number)==
''){$error_msg.=
"Please enter a (Valid) Security Code !<br>";
} else {// check if numbers matches each other
$session_num = (int) $_SESSION['number'];
$post_num = (int) $_POST['number'];
if (!($session_num == $post_num)) $error_msg.="Wrong value entered!<br>";
}
// display error message if any, if not, proceed to other processing
if(mail($to,
$subject,
$body)) { echo "Thanks <b>$name</b>, <br>Your message has been submitted to <br><b>$to</b></br>!</br>";
//display the message to say that your message was sent to.... echo '<br><a href="' .
$continue .
'">Click here to continue.</a>';
}
else {
echo "<font color=red>please try again later</font>";
//there was an error with the mail function - please try again later }
}
else {echo "<font color=red>$error_msg</font>";
}
}
//mail($to, $subject, $body);
?>
</div>
</div>
</div>
<div>
<PRE>
<?php
// For diagnostics
//echo "POST<HR>";
//print_r($_POST);
//echo "SESSION<HR>";
//print_r($_SESSION);
//echo "<HR>";
?>
</PRE>
</DIV>
</body>
</html>