";
} else {
$name = test_input($_POST["name"]);
}
if (empty($_POST["email"])) {
$emailErr = "Email is required.
";
} else {
$email = test_input($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email address.
";
}
}
if (empty($_POST["subject"])) {
$subject = "";
} else {
$subject = test_input($_POST["subject"]);
}
if (empty($_POST["msg"])) {
$msgErr = "Message is empty.
";
} else {
$message = test_input($_POST["msg"]);
}
if (($emailErr == "") && ($nameErr == "") && ($msgErr == "")) {
$to = "brianwestleycoaching.outlook.com";
$headers = "From: $name\r\n";
$news = true;
mail($to,$subject,$message,$headers);
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
You can email me at brianwestleycoaching@outlook.com or fill out the form below and I'll get back to you!
";
}
echo $nameErr.$emailErr.$msgErr;
?>