-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact.php
More file actions
71 lines (65 loc) · 2.87 KB
/
contact.php
File metadata and controls
71 lines (65 loc) · 2.87 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "weDecideDB";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$message = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $conn->real_escape_string(trim($_POST['name']));
$email = $conn->real_escape_string(trim($_POST['email']));
$subject = $conn->real_escape_string(trim($_POST['subject']));
$messageContent = $conn->real_escape_string(trim($_POST['message']));
$sql = "INSERT INTO contacts (name, email, subject, message) VALUES ('$name', '$email', '$subject', '$messageContent')";
if ($conn->query($sql) === TRUE) {
$message = "Message sent successfully!";
} else {
$message = "Error: " . $sql . "<br>" . $conn->error;
}
}
$conn->close();
?>
<title>Contact Us - weDecide</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
<body>
<?php include 'include/header.php'?>
<div class="contact_container">
<div class="image-section">
<img src="assets/images/contact.png" alt="Contact Illustration" />
</div>
<div class="contact_form">
<h2>GET IN TOUCH WITH US</h2>
<?php if ($message): ?>
<div class="alert"><?php echo $message; ?></div>
<?php endif; ?>
<form action="contact.php" method="POST">
<div class="input-group">
<label for="name">Your Name</label>
<input type="text" id="name" name="name" placeholder="Enter Your Name" required />
</div>
<div class="input-group">
<label for="email">Your Email</label>
<input type="email" id="email" name="email" placeholder="Enter Your Email" required />
</div>
<div class="input-group full-width">
<label for="subject">Subject</label>
<input type="text" id="subject" name="subject" placeholder="Enter Subject." required />
</div>
<div class="input-group full-width">
<label for="message">Your Message</label>
<textarea id="message" name="message" placeholder="Enter Your Message" rows="5" required></textarea>
</div>
<div class="input-group full-width">
<button type="submit">Send Message</button>
</div>
</form>
</div>
</div>
<script src="assets/js/script.js"></script>
</body>
</html>