validate email address to prevent header injection

main
Greg Molnar 10 years ago
parent 01f53b4d6f
commit 4754596ded

@ -11,10 +11,15 @@ if(empty($_POST['name']) ||
} }
$name = $_POST['name']; $name = $_POST['name'];
$email_address = $_POST['email']; $email_address = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
if ($email === FALSE) {
echo 'Invalid email';
exit(1);
}
$phone = $_POST['phone']; $phone = $_POST['phone'];
$message = $_POST['message']; $message = $_POST['message'];
// Create the email and send the message // Create the email and send the message
$to = 'yourname@yourdomain.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to. $to = 'yourname@yourdomain.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
$email_subject = "Website Contact Form: $name"; $email_subject = "Website Contact Form: $name";

Loading…
Cancel
Save