-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.php
More file actions
35 lines (27 loc) · 1.01 KB
/
Copy pathcontact.php
File metadata and controls
35 lines (27 loc) · 1.01 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
35
<?php
// Database connection
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "wave_studio_interior";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Fetch form data
$name = $conn->real_escape_string($_POST['name']);
$phone = $conn->real_escape_string($_POST['phone']);
$email = $conn->real_escape_string($_POST['email']);
$subject = $conn->real_escape_string($_POST['subject']);
$message = $conn->real_escape_string($_POST['message']);
// Insert query
$sql = "INSERT INTO contact_info (name, phone, email, subject, message)
VALUES ('$name', '$phone', '$email', '$subject', '$message')";
if ($conn->query($sql) === TRUE) {
echo "<script>alert('Message Sent Successfully'); window.location.href='contact.html';</script>";
} else {
echo "<script>alert('Error sending message'); window.location.href='contact.html';</script>";
}
$conn->close();
?>