Here is the PHP code:
<?php
var_dump($_POST);
// Check for empty fields
if (isset($_POST['button'])) {
empty($_POST['name'])
empty($_POST['email'])
empty($_POST['phone'])
empty($_POST['message'])
echo "You gotta fill it out!";
return false;
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$to = 'ned@nerdcorestudio.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
$subject = "Website Contact Form: $name";
$text = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email\n\nPhone: $phone\n\nMessage:\n$message";
$header = "From: noreply@yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
mail($to,$subject,$text,$header);
header("Location: index.html?mailsent")
return true;
if(mail($to, $subject, $text, $header)) {
echo 'Thank You!';
} else {
echo 'boo, no email was sent';
}
?>