-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_query.php
More file actions
29 lines (26 loc) · 1005 Bytes
/
submit_query.php
File metadata and controls
29 lines (26 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve form data
$name = htmlspecialchars(strip_tags(trim($_POST['name'])));
$email = htmlspecialchars(strip_tags(trim($_POST['email'])));
$phone = htmlspecialchars(strip_tags(trim($_POST['phone'])));
$message = htmlspecialchars(strip_tags(trim($_POST['message'])));
// Validate the inputs (basic validation)
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
die("Invalid email format");
}
// Prepare the email
$to = 'atishlibun@gmail.com';
$subject = 'New Contact Form Submission';
$body = "Name: $name\nEmail: $email\nPhone: $phone\nMessage: $message";
$headers = "From: $email" . "\r\n" . "Reply-To: $email";
// Send the email
if (mail($to, $subject, $body, $headers)) {
echo "Message sent successfully!";
} else {
echo "Failed to send message. Please try again later.";
}
} else {
echo "Invalid request method.";
}
?>