-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit_contact.php
More file actions
34 lines (27 loc) · 1.13 KB
/
Copy pathsubmit_contact.php
File metadata and controls
34 lines (27 loc) · 1.13 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
34
<?php
// Database connection
$mysqli = new mysqli("localhost", "root", "", "shieldmaidens_db", 3308); // 3308 is your port
if ($mysqli->connect_error) {
die("Connection failed: " . $mysqli->connect_error);
}
// Get form data
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// Insert into database
$stmt = $mysqli->prepare("INSERT INTO contact_messages (name, email, message) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $name, $email, $message);
$stmt->execute();
// Send email to admin
$admin_email = "shi3ldmaidens@gmail.com";
$subject = "New Contact Message from $name";
$body = "You have received a new message from your website contact form:\n\nName: $name\nEmail: $email\nMessage:\n$message";
mail($admin_email, $subject, $body);
// Send confirmation email to user
$user_subject = "Thank you for contacting Shieldmaidens!";
$user_body = "Thank you for contacting Shieldmaidens, where we value inclusivity, empowerment, and safety. Our team will get back to you shortly.\n\nWith love, 💖\nShieldmaidens Team";
mail($email, $user_subject, $user_body);
$stmt->close();
$mysqli->close();
echo "success";
?>