-
Notifications
You must be signed in to change notification settings - Fork 2
/
contact.php
361 lines (303 loc) · 10.8 KB
/
contact.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<?php
// Include packages and files for PHPMailer and SMTP protocol
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
// Initialize PHP mailer, configure to use SMTP protocol and add credentials
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->SMTPDebug = 0;
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "ssl";
$mail->Port = 465;
$mail->Host = "smtp.gmail.com";
$mail->Username = "eclassroom1999@gmail.com";
$mail->Password = "dmcgocrdifnyjmbw";
$success = "";
$error = "";
$name = $message = $email = "";
$errors = array('name' => '', 'email' => '', 'message' => '');
$mymail = 'ab007shetty@gmail.com';
$myname = 'Quiz Master';
if (isset($_POST["submit"])) {
if (empty(trim($_POST["name"]))) {
$errors['name'] = "Your name is required";
} else {
$name = SanitizeString($_POST["name"]);
if (!preg_match('/^[a-zA-Z\s]{6,50}$/', $name)) {
$errors['name'] = "Only letters and spaces allowed";
}
}
if (empty(trim($_POST["email"]))) {
$errors["email"] = "Your email is required";
} else {
$email = SanitizeString($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$errors["email"] = "Pls give a proper email address";
}
}
if (empty(trim($_POST["message"]))) {
$errors["message"] = "Please type your message";
} else {
$message = SanitizeString($_POST["message"]);
if (!preg_match("/^[a-zA-Z\d\s]+$/", $message)) {
$errors["message"] = "Only letters, spaces and maybe numbers allowed";
}
}
if (array_filter($errors)) {
} else {
try {
$mail->setFrom('eclassroom1999@gmail', 'Quiz Master');
$mail->addAddress($mymail, $myname);
$mail->Subject = 'Online Quiz Management System - Contact Form';
$mail->Body = $message;
// send mail
$mail->send();
// empty users input
$name = $message = $email = "";
$success = "Message sent successfully";
} catch (Exception $e) {
// echo $e->errorMessage(); use for testing & debugging purposes
$error = "Sorry message could not send, try again";
} catch (Exception $e) {
// echo $e->getMessage(); use for testing & debugging purposes
$error = "Sorry message could not send, try again";
}
}
}
function SanitizeString($var)
{
$var = strip_tags($var);
$var = htmlentities($var);
return stripslashes($var);
}
?>
<!DOCTYPE html>
<html>
<?php require ("header.php");?>
<style>
.error {
color: white;
background-color: crimson;
border-radius: 7px;
text-align: center;
}
.success {
background-color: darkgreen;
color: white;
border-radius: 7px;
text-align: center;
}
</style>
<body class="bg-white" id="top">
<!-- Navbar -->
<nav
id="navbar-main"
class="
navbar navbar-main navbar-expand-lg
bg-default
navbar-light
position-sticky
top-0
shadow
py-0
"
>
<div class="container">
<ul class="navbar-nav navbar-nav-hover align-items-lg-center">
<li class="nav-item dropdown">
<a href="index.php" class="navbar-brand mr-lg-5 text-white">
<img src="assets/img/navbar.png" />
</a>
</li>
</ul>
<button
class="navbar-toggler bg-white"
type="button"
data-toggle="collapse"
data-target="#navbar_global"
aria-controls="navbar_global"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon text-white"></span>
</button>
<div class="navbar-collapse collapse bg-default" id="navbar_global">
<div class="navbar-collapse-header">
<div class="row">
<div class="col-10 collapse-brand">
<a href="index.html">
<img src="assets/img/navbar.png" />
</a>
</div>
<div class="col-2 collapse-close bg-danger">
<button
type="button"
class="navbar-toggler"
data-toggle="collapse"
data-target="#navbar_global"
aria-controls="navbar_global"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span></span>
<span></span>
</button>
</div>
</div>
</div>
<ul class="navbar-nav align-items-lg-center ml-auto">
<li class="nav-item">
<a href="contact.php" class="nav-link">
<span class="text-success nav-link-inner--text"
><i class="text-success fas fa-address-card"></i> Contact</span
>
</a>
</li>
<li class="nav-item">
<div class="dropdown show ">
<a class="nav-link dropdown-toggle text-white " href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="text-white nav-link-inner--text"
><i class="text-white fas fa-sign-in-alt"></i> Login</span
>
</a>
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
<a class="dropdown-item" href="loginstud.php">Student</a>
<a class="dropdown-item" href="login.php">Staff</a>
</div>
</div>
</li>
<li class="nav-item">
<a href="signup.php" class="nav-link">
<span class="text-white nav-link-inner--text"
><i class="text-white fas fa-user-plus"></i> Sign Up</span
>
</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
<section class="section section-shaped section-lg">
<div class="shape shape-style-1 shape-primary">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
<!-- ======================================================================================================================================== -->
<div class="container">
<div class="row">
<div class="col-md-8 mx-auto text-center">
<span class="badge badge-warning badge-pill mb-3">Contact</span>
</div>
</div>
<div class="row row-content align-text-center">
<div class="col-12">
<div class="col-12">
<div class="card card-body bg-dark">
<div class="success"><?php echo $success ?></div>
<div class="error"><?php echo $error ?></div>
<form
action="contact.php"
method="post"
>
<div class="form-group row">
<label for="name" class="col-md-2 col-form-label"
><h6 class="text-white">Name</h6>
</label>
<div class="col-md-10">
<input
type="text"
class="form-control"
required
id="name"
name="name"
placeholder="Full Name"
value="<?php echo htmlspecialchars($name) ?>"
/>
</div>
</div>
<div class="form-group row">
<label for="emailid" class="col-md-2 col-form-label">
<h6 class="text-white">Email</h6></label
>
<div class="col-md-10">
<input
type="email"
class="form-control"
required
id="email"
name="email"
placeholder="abc@xyz.com"
value="<?php echo htmlspecialchars($email) ?>"
/>
<div class="error"><?php echo $errors["email"] ?></div>
</div>
</div>
<div class="form-group row">
<label for="feedback" class="col-md-2 col-form-label">
<h6 class="text-white">Message</h6></label
>
<div class="col-md-10">
<textarea
class="form-control"
id="message"
name="message"
placeholder="Your Message..."
rows="5"
<?php echo htmlspecialchars($message) ?>
></textarea>
<div class="error"><?php echo $errors["message"] ?></div>
</div>
</div>
<div class="form-group row">
<div class="offset-md-2 col-md-2">
<button
type="submit"
class="btn btn-danger"
name="submit" id="submit" value="Send"
>
SEND
</button>
</div>
<div class="offset-md-3 text-justify-content-end">
<div class="btn-group" role="group">
<a
role="button"
class="btn btn-info"
href="tel:+918317308812"
><i class="fa fa-phone"></i> Call</a
>
<a role="button" class="btn btn-success" target="_blank" href="http://wa.me/916366004459?text=Message%20From%20Quiz%20Master."
><i class="fa fa-whatsapp"></i> Whatsapp</a
>
<a
role="button"
class="btn btn-primary"
href="mailto:parikshithsshetty59@gmail"
><i class="fa fa-envelope-o"></i> Email</a
>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</section>
<?php require("footer.php");?>
</body>
</html>