-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontacts.php
64 lines (51 loc) · 1.63 KB
/
contacts.php
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
<?php include('partials-front/menu.php'); ?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/contact.css">
<title>Contact Us</title>
</head>
<body>
<header>
<h1>Contact Us</h1>
</header>
<section class="contact-form">
<?php
?>
<form action=" " method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="message">Message:</label>
<textarea id="message" name="message" rows="4" required></textarea>
<input type="submit" name="submit" value="Submit">
</form>
</section>
</body>
</html>
<?php
// Start Session
if(isset($_POST['submit'])){
if(isset($_POST['name'])) {
$name = $_POST['name'];
}
if(isset($_POST['email'])) {
$email = $_POST['email'];
}
if(isset($_POST['message'])) {
$message = $_POST['message'];
}
$sql = "INSERT INTO tbl_contacts (name, email, message) VALUES ('$name', '$email', '$message')";
// Execute query
if (mysqli_query($conn, $sql)) {
echo "<div class='message'>------------------------Submitted successfully! We will Get Back to you shortly---------------------------</div>";
} else {
echo "Error: " . mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
}
?>