generated from Templates_CodeFirst/templateHtmlCss
fix form
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
c85b6616c0
commit
cd7570f972
@ -0,0 +1,29 @@
|
|||||||
|
document.getElementById("contact-form").addEventListener("submit", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Get form values
|
||||||
|
const name = document.getElementById("name").value;
|
||||||
|
const email = document.getElementById("email").value;
|
||||||
|
const message = document.getElementById("message").value;
|
||||||
|
|
||||||
|
// Prepare parameters for EmailJS
|
||||||
|
const params = {
|
||||||
|
from_name: name,
|
||||||
|
from_email: email,
|
||||||
|
message: message,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Send email using EmailJS
|
||||||
|
emailjs.send("service_auuixzl", "template_9w001tg", params)
|
||||||
|
.then(response => {
|
||||||
|
document.getElementById("response-message").textContent =
|
||||||
|
"Your message has been sent successfully!";
|
||||||
|
document.getElementById("response-message").classList.remove("hidden");
|
||||||
|
document.getElementById("contact-form").reset();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
document.getElementById("response-message").textContent =
|
||||||
|
"There was an error sending your message. Please try again.";
|
||||||
|
document.getElementById("response-message").classList.remove("hidden");
|
||||||
|
});
|
||||||
|
});
|
@ -1,33 +0,0 @@
|
|||||||
<?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.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
Loading…
Reference in new issue