<?php
if ($_POST){
if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)){
echo ('<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">
<b>' . $_POST['email'] . '</b> Email is not valid. Return to previous page and enter a valid email.
</div>');
} else {
$body = "";
foreach ($_POST as $param_name => $param_val) {
$body .= "$param_name: $param_val\n";
}
$headers = 'From: ' .$_POST['email'];
if (mail("[email address removed by Mod]", "Contact form submitted.", $body, $headers)) {
header('Location: http://www.winvoices.com/success.php');
} else {
$message = 'Sorry an error occurred. Please try again later.';
}
}
}
?>
Include the code marked in red below. It tests the Miscellaneous form field for any instances of 'http' or 'HTTP'. If it finds any the script stops running 'exit';
It's best to try it out by inputting http or HTTP in the form field - you should get a blank page and no email send through.
<?php
if ($_POST){
if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)){
echo ('<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">
<b>' . $_POST['email'] . '</b> Email is not valid. Return to previous page and enter a valid email.
</div>');
} else {
$body = "";
$Miscellaneous = $_POST['Miscellaneous'];
if (preg_match("~\bhttp\b~", $Miscellaneous) or preg_match("~\bHTTP\b~", $Miscellaneous)) {
exit;
}
else {
foreach ($_POST as $param_name => $param_val) {
$body .= "$param_name: $param_val\n";
}
}
$headers = 'From: ' .$_POST['email'];
if (mail("[email address removed by Mod]", "Contact form submitted.", $body, $headers)) {
header('Location: http://www.winvoices.com/success.php');
} else {
$message = 'Sorry an error occurred. Please try again later.';
}
}
}
?>