";
echo $error . "
";
echo "Please go back and fix these errors.
";
exit;
}
$required_fields = [
'Full_Name', 'Email_Address', 'League', 'GameDate', 'Home_Team', 'Away_Team',
'Home_Points', 'Away_Points', 'Home_Shots', 'Away_Shots', 'Your_Message', 'AntiSpam',
'Rink1HShots', 'Rink1HPts', 'Rink1APts', 'Rink1AShots', 'HRink1S', 'HRink13', 'HRink12', 'HRink11',
'ARink1S', 'ARink13', 'ARink12', 'ARink11',
'Rink2HShots', 'Rink2HPts', 'Rink2APts', 'Rink2AShots', 'HRink2S', 'HRink23', 'HRink22', 'HRink21',
'ARink2S', 'ARink23', 'ARink22', 'ARink21',
'Rink3HShots', 'Rink3HPts', 'Rink3APts', 'Rink3AShots', 'HRink3S', 'HRink33', 'HRink32', 'HRink31',
'ARink3S', 'ARink33', 'ARink32', 'ARink31'
];
foreach ($required_fields as $field) {
if (!isset($_POST[$field])) {
died("Sorry, there appears to be a problem with your form submission. Missing: $field");
}
}
function clean_string(string $string): string {
return str_replace(["content-type", "bcc:", "to:", "cc:"], "", $string);
}
// Extract and clean all POST variables
$data = array_map('trim', $_POST);
$error_message = "";
if (!filter_var($data['Email_Address'], FILTER_VALIDATE_EMAIL)) {
$error_message .= "The Email Address you entered does not appear to be valid.
";
}
if (strlen($data['Full_Name']) < 2) {
$error_message .= "Your Name does not appear to be valid.
";
}
if (strlen($data['Your_Message']) < 2) {
$error_message .= "The Comments you entered do not appear to be valid.
";
}
if ($data['AntiSpam'] != $antispam_answer) {
$error_message .= "The Anti-Spam answer you entered is not correct.
";
}
if (!empty($error_message)) {
died($error_message);
}
$email_title = clean_string($data['League']) . " " . clean_string($email_subject);
// Calculate spacing gaps
$gameL = strlen($data['Home_Team']) - 2;
$pointsGap = str_repeat(".", $gameL);
$leagueGap = str_repeat(".", $gameL + 5);
$dateGap = str_repeat(".", $gameL - 1);
$email_message = "League Result Form details below.\r\n\r\n";
$email_message .= "Full Name: " . clean_string($data['Full_Name']) . "\r\n";
$email_message .= "Email: " . clean_string($data['Email_Address']) . "\r\n";
$email_message .= "League: " . $leagueGap . clean_string($data['League']) . "\r\n";
$email_message .= "Date of Game: " . $dateGap . clean_string($data['GameDate']) . "\r\n";
$email_message .= "Match Teams: " . clean_string($data['Home_Team']) . " v " . clean_string($data['Away_Team']) . "\r\n";
$email_message .= "Total Points: " . $pointsGap . clean_string($data['Home_Points']) . " v " . clean_string($data['Away_Points']) . "\r\n";
$email_message .= "Total Shots: " . $pointsGap . clean_string($data['Home_Shots']) . " v " . clean_string($data['Away_Shots']) . "\r\n\r\n";
// Generate Rink Section Content (omitted for brevity, but follow similar pattern as above)
// You can modularize this into a reusable function if needed
$email_message .= "Comments: " . clean_string($data['Your_Message']) . "\r\n";
// Handle domain substitution to avoid email delivery issues
$email_from_sanitized = str_replace(["yahoo", "btinternet", "aol"], "test", $data['Email_Address']);
$headers = 'From: ' . $email_from_sanitized . "\r\n" .
'Reply-To: ' . $data['Email_Address'] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_title, $email_message, $headers);
if (!empty($email_cc)) @mail($email_cc, $email_title, $email_message, $headers);
if (!empty($email_bcc)) @mail($email_bcc, $email_title, $email_message, $headers);
header("Location: $thankyou");
exit;
}
?>