"; echo ""; echo "Message Not Sent - Ascot Pet Boarding"; echo ""; echo "

We could not send your message.

"; echo "

" . htmlspecialchars($message, ENT_QUOTES, 'UTF-8') . "

"; echo "

Please call Ascot Pet Boarding at "; echo "(803) 327-4883.

"; echo "

Return to Contact Page

"; echo ""; exit; } if ($_SERVER['REQUEST_METHOD'] !== 'POST') { header("Location: contact.html"); exit; } /* Spam protection */ if (!empty($_POST['website'])) { show_error("Your message could not be processed."); } /* Collect submitted information */ $name = trim((string)($_POST['Name'] ?? '')); $email = trim((string)($_POST['Email'] ?? '')); $message = trim((string)($_POST['Message'] ?? '')); /* Validate required fields */ if ($name === '' || $email === '' || $message === '') { show_error("Please complete all required fields."); } if (strlen($name) > 150 || strlen($email) > 254) { show_error("Please check your name and email address."); } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { show_error("Please enter a valid email address."); } if (strlen($message) < 2 || strlen($message) > 3000) { show_error("Please enter a message between 2 and 3000 characters."); } /* Remove line breaks and control characters from header fields */ $name = preg_replace('/[\r\n\x00-\x1F\x7F]+/', ' ', $name); $email = preg_replace('/[\r\n\x00-\x1F\x7F]+/', '', $email); /* Build email message */ $email_message = "A new inquiry was submitted through the Ascot Pet Boarding website.\n\n" . "Name: " . $name . "\n" . "Email: " . $email . "\n\n" . "Message:\n" . $message . "\n\n" . "----------------------------------------\n" . "Sent from: AscotPetBoarding.com\n"; /* Email headers */ $headers = array( "From: Ascot Website ", "Reply-To: " . $email, "MIME-Version: 1.0", "Content-Type: text/plain; charset=UTF-8" ); /* Attempt to send email */ $mail_sent = mail( $email_to, $email_subject, $email_message, implode("\r\n", $headers) ); /* Redirect only if PHP accepted the message for sending */ if ($mail_sent) { header("Location: " . $thank_you_page); exit; } /* Log failure without exposing server details to visitors */ error_log("Ascot contact form: PHP mail() returned false."); show_error( "There was a problem sending your message. Please call us directly." ); ?>