-
Notifications
You must be signed in to change notification settings - Fork 2
/
contact_us.php
153 lines (130 loc) · 5.37 KB
/
contact_us.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
session_start();
// including database connection
require('env/database.php');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Contact Us</title>
<link rel="icon" type="image/x-icon" href="assets/svg-logo/logo-bg.svg">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" />
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://kit.fontawesome.com/db79afedbd.js" crossorigin="anonymous"></script>
<script src="jquery.js"></script>
<script src="main.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="assets/css/main.css" />
</head>
<body>
<!-- ----------------------------------------------------Loading Screen-------------------------------------------------------- -->
<div id="loading">
<img src="assets/svg-logo/LOADER.svg" alt="Loading..." />
</div>
<script>
var loader = document.getElementById("loading");
window.addEventListener("load", function() {
loader.style.display = "none";
})
</script>
<?php
// including header
include 'header.php';
?>
<!-------------------------------------------------body----------------------------------------------------------->
<div class="container-fluid my-5">
<div class="row justify-content-center">
<div class="col-xl-6 col-sm-12">
<div class="card border-0 rounded-3 shadow-lg overflow-hidden">
<div class="card-body p-0">
<div class="row g-0 d-flex justify-content-center">
<div class="col-sm-12 p-4">
<div class="text-center">
<div class="h3 fw-light">Contact Form</div>
<p class="mb-4 text-muted">Grapple Inc.</p>
</div>
<form method="post">
<!-- Name Input -->
<div class="form-floating mb-3">
<input class="form-control" id="name" type="text" placeholder="Enter Your Name" name="name" data-sb-validations="required" />
<label for="name">Name</label>
</div>
<!-- Email Input -->
<div class="form-floating mb-3">
<input class="form-control" id="emailAddress" type="email" placeholder="Enter Your Email Address" name="email" data-sb-validations="required,email" />
<label for="emailAddress">Email Address</label>
</div>
<!-- Message Input -->
<div class="form-floating mb-3">
<textarea class="form-control" id="message" name="message" type="text" placeholder="Enter Message" style="height: 10rem;" data-sb-validations="required"></textarea>
<label for="message">Message</label>
</div>
<!-- Showing Captcha -->
<div>
<img src="captcha.php" alt="captcha" /><br><br>
</div>
<!-- Captcha Input -->
<div class="form-floating mb-3">
<input type="text" name="captcha" id="captcha" class="form-control form-control-lg" placeholder="Enter Captcha Code" />
<label for="captcha">Captcha Code</label>
</div>
<!-- Submit button -->
<div class="d-grid">
<button class="btn btn-primary btn-lg " name="submit" id="submitButton" type="submit">Submit</button>
</div>
</form>
<!-- End of contact form -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
// checking if submit button is clicked
if (isset($_POST['submit'])) {
// checking if captcha is matched
if ($_SESSION['captcha'] == $_POST['captcha']) {
// taking form data into variables
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
// sql query to insert data into database
$sql = "INSERT INTO `contact` (`name`, `email`, `message`) VALUES ('$name', '$email', '$message')";
// executing query
$result = mysqli_query($conn, $sql);
// checking if query is executed
if ($result) {
echo "<script>
toastr.options.closeButton = true;
toastr.options.progressBar = true;
toastr['success']('We Received Your Message.');
</script>";
} else {
echo "<script>
toastr.options.closeButton = true;
toastr.options.progressBar = true;
toastr['error']('Something went wrong.');
</script>";
}
} else {
echo "<script>
toastr.options.closeButton = true;
toastr.options.progressBar = true;
toastr['error']('Wrong Captcha!');
</script>";
} // end of if of captcha
} // end of if of submit button
?>
<!------------------------------------------------- footer ----------------------------------------------------------->
<?php
// including footer
include 'footer.php';
?>
</body>
</html>