$feed_first = filter_input(INPUT_POST, "feed_first", FILTER_SANITIZE_STRING);
$feed_last= filter_input(INPUT_POST, "feed_last", FILTER_SANITIZE_STRING);
$feed_phone= filter_input(INPUT_POST, "feed_phone", FILTER_SANITIZE_STRING);
$form_email= filter_input(INPUT_POST, "form_email", FILTER_SANITIZE_STRING);
$feed_comments= filter_input(INPUT_POST, "feed_comments", FILTER_SANITIZE_STRING);
$Code= filter_input(INPUT_POST, "Code", FILTER_SANITIZE_STRING);
if(isset($_POST['form_email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to =32div.info@32nd-division.org";
# $email_to = "webmaster@oldcabin.net";
$femail= "noreply@32nd-division.org";
$email_subject = "32D Red Arrow Web site Request";
function died($error) {
echo "
We are very sorry, but there were error(s) found with the form you submitted
“;
echo “
“;
echo “
Please go back and correct these errors:“;
echo “
“;
}
function clean_string($string) {
$bad = array(“content-type”,”bcc:”,”to:”,”cc:”,”href”);
return str_replace($bad,””,$string);
}
// validation expected data exists
if(!isset($feed_first) ||
!isset($_POST[‘feed_last’]) ||
!isset($_POST[‘form_email’]))
{
died(‘We are sorry, but there appears to be a problem with the form you submitted.’);
}
# $feed_first = $_POST[‘feed_first’]; // required
# $feed_last = $_POST[‘feed_last’]; // required
#$form_email = clean_data( $_POST[‘form_email’] );
#$feed_first = clean_data( $_POST[‘feed_first’] );
#$feed_last = clean_data( $_POST[‘feed_last’] );
#$feed_phone = clean_data( $_POST[‘feed_phone’] );
#$feed_comments = clean_data( $_POST[‘feed_comments’] );
$feed_comments = $_POST[‘feed_comments’]; // optional
$Code= $_POST[‘Code’];
# $feed_interest = ‘None’;
# if(isset($_POST[‘feed_interest’]) && is_array($_POST[‘feed_interest’]) && count($_POST[‘feed_interest’]) > 0){
# $feed_interest = implode(‘, ‘, $_POST[‘feed_interest’]);
# }
$contact_url = “https://www.32nd-division.org/contact/”;
$realip = $_SERVER[‘REMOTE_ADDR’];
$iprefer = $_SERVER[‘HTTP_REFERER’];
$error_message = “”;
$code2 = “28Xp53b”;
if ($Code !== $code2) {
$error_message .= ‘
You must enter the security code or the Code is incorrect: You entered ‘ . $Code . ‘. The correct code is ‘. $code2 .’ and the code is CASE Sensitive‘;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if ($iprefer !== $contact_url) {
$error_message .= ‘
You are trying to call this form from an unauthorized URL. How come? ‘;
}
$string_exp = “/^[A-Za-z .’-]+$/”;
if(!preg_match($string_exp,$feed_first)) {
$error_message .= ‘
The first name you entered does not appear to be valid.‘;
}
if(!preg_match($string_exp,$feed_last)) {
$error_message .= ‘
The last name you entered does not appear to be valid.‘;
}
//do nothing for phone as not required
$email_exp = ‘/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/’;
if(!preg_match($email_exp,$form_email)) {
$error_message .= ‘
The email address you entered does not appear to be valid.‘;
}
if(strlen($error_message) > 0) {
died($error_message);
}else{
echo “
Thank you for your inquiry
“;
echo “
“;
echo “We will be in touch with you very soon.
“;
echo “
“;
echo “
“;
echo ““;
$email_message = “$email_subject \n”;
$email_message .= “\n”;
$email_message .= “************************************************************* \n”;
$email_message .= “First name: “.clean_string($feed_first).”\n”;
$email_message .= “Last name: “.clean_string($feed_last).”\n”;
$email_message .= “Phone: “.clean_string($feed_phone).”\n”;
$email_message .= “Email address: “.clean_string($form_email).”\n\n”;
$email_message .= “Questions: “.clean_string($feed_comments).”\n\n”;
$email_message .= “IP Address: “.$realip.”\n”;
// create email headers
$headers = ‘From: ‘.$femail.”\r\n”.
‘Reply-To: ‘.$form_email.”\r\n” .
‘X-Mailer: PHP/’ . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
}
} ?>