
if(isset($_POST['submit'])) {
//Check for missing fields
$required = array("Name","Email","Comments");
foreach($required as $k){
if($_POST["$k"] == ""){
$errmsg .= "$k Missing
";
$error = 1;
}
}
//CONVERT TO STRINGS
foreach($_POST as $key => $value){
$$key = $_POST["$key"];
}
$interest_array = array(1 => "Basic Sewing Lessons",2 => "Quilting Lessons",3 => "Basket Weaving Lessons");
foreach($interest_array as $key => $value){
if(in_array($value,$interest)){
$newvar = "check".$key;
$$newvar = "checked=\"checked\"";
}
}
if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
unset($_SESSION['security_code']);
} else {
$error = 1;
$errmsg .= "Invalid Security Code";
}
if($error == 1){ //SHOW ERRORS
?>
Your form could not be submitted for the following reasons:
Please click your back button and re-enter the missing fields.
} else { //EMAIL FORM
unset($_POST['security_code']);
unset($_POST["submit"]);
foreach($_POST as $key => $value){
if($key == "interest" && $value != ""){
$int = $_POST["$key"];
for($i=0; $i< count($int); $i++){
$list .= "-".$int[$i]."\n";
}
$msg .= "I'm interested in:\n$list\n";
} else {
$msg .= "$key: $value\n";
}
}
$message = "This message was submitted through fiberartist.com. Do not reply directly to this email. Instead, use the email entered below. \n\n $msg";
mail("pamkay@fiberartist.com","Webmail from fiberartist.com","$message","From:Fiberartist.com Webmail
");
echo "Thank you for contacting me! I will respond as soon as possible.";
}
} else {
?>
} ?>