File indexing completed on 2025-01-18 09:27:06
0001 <?php
0002 if ($_SERVER["REQUEST_METHOD"] == "POST") {
0003
0004 $firstName = htmlspecialchars(stripslashes(trim($_POST['firstName'])));
0005 $lastName = htmlspecialchars(stripslashes(trim($_POST['lastName'])));
0006 $email = filter_var(trim($_POST['email']), FILTER_SANITIZE_EMAIL);
0007 $message = htmlspecialchars(stripslashes(trim($_POST['message'])));
0008
0009
0010 if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
0011 echo "Invalid email format";
0012 exit;
0013 }
0014
0015
0016 $to = 'roark@jlab.org';
0017 $subject = 'New Contact Form Submission';
0018
0019
0020 $email_content = "First Name: $firstName\n";
0021 $email_content .= "Last Name: $lastName\n";
0022 $email_content .= "Email: $email\n";
0023 $email_content .= "Message: $message\n";
0024
0025
0026 $headers = "From: $email";
0027
0028
0029 if(mail($to, $subject, $email_content, $headers)) {
0030 echo "Thank You! Your message has been sent.";
0031 } else {
0032 echo "Oops! Something went wrong and we couldn't send your message.";
0033 }
0034 } else {
0035
0036 http_response_code(403);
0037 echo "There was a problem with your submission, please try again.";
0038 }
0039 ?>