generated from Templates_CodeFirst/templateHtmlCss
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.0 KiB
34 lines
1.0 KiB
<?php
|
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|
$name = htmlspecialchars($_POST['name']);
|
|
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
|
|
$message = htmlspecialchars($_POST['message']);
|
|
|
|
if ($name && $email && $message) {
|
|
// Recipient email
|
|
$to = "corentin.caillot03@gmail.com";
|
|
|
|
// Email subject
|
|
$subject = "New Contact Form Submission";
|
|
|
|
// Email content
|
|
$body = "You have received a new message from your website's contact form:\n\n";
|
|
$body .= "Name: $name\n";
|
|
$body .= "Email: $email\n";
|
|
$body .= "Message:\n$message\n";
|
|
|
|
// Email headers
|
|
$headers = "From: $email";
|
|
|
|
// Send the email
|
|
if (mail($to, $subject, $body, $headers)) {
|
|
echo "Your message has been sent successfully!";
|
|
} else {
|
|
echo "There was an issue sending your message. Please try again later.";
|
|
}
|
|
} else {
|
|
echo "Invalid input. Please make sure all fields are filled out correctly.";
|
|
}
|
|
}
|
|
?>
|