-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_form.php
More file actions
35 lines (29 loc) · 1.04 KB
/
submit_form.php
File metadata and controls
35 lines (29 loc) · 1.04 KB
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
30
31
32
33
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars($_POST['name']);
$email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL);
$subject = htmlspecialchars($_POST['subject']);
$message = htmlspecialchars($_POST['message']);
if ($name && $email && $subject && $message) {
$to = "0twodevils0@gmail.com";
$email_subject = "Contact Form Submission: $subject";
$email_body = "Name: $name\n";
$email_body .= "Email: $email\n";
$email_body .= "Subject: $subject\n";
$email_body .= "Message:\n$message";
$headers = "From: noreply@yourdomain.com";
if (mail($to, $email_subject, $email_body, $headers)) {
echo "Message sent successfully!";
} else {
error_log("Mail function failed.");
echo "Failed to send message. Check error log for details.";
}
} else {
echo "Please complete all fields.";
}
} else {
echo "Invalid request.";
}
?>