-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
95 lines (86 loc) · 3.06 KB
/
Copy pathindex.php
File metadata and controls
95 lines (86 loc) · 3.06 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
error_reporting(1);
require_once "./connection/db_connection.php";
require_once "./mailer.php";
function getHostLink($folderPath = "")
{
$link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]/" . ltrim($folderPath, "/");
return rtrim($link, "/");
}
if (isset($_POST['verifyMail'])) {
$sent = "";
$className = "";
$recipientEmail = trim($_POST['email_id']);
$subject = "Verify your mail";
$folderPath = dirname($_SERVER['REQUEST_URI']) . "/verify_email.php?email=" . $recipientEmail;
$msgContent = "Please verify your mail by clicking <a href='" . getHostLink($folderPath) . "'>here</a>";
$attachment = null;
$sql = "INSERT INTO email_list VALUES(default,'$recipientEmail',0)";
if (mysqli_query($connection, $sql)) {
if (emailSending($recipientEmail, $subject, $msgContent)) {
$msgSend = "A verification link is being sent to your email.";
$className = "success";
} else {
$msgSend = "Could not sent verification link to your email";
$className = "danger";
}
} else {
$msgSend = "Cannot insert";
$className = "danger";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email verification</title>
<link rel="stylesheet" href="./bootstrap.min.css" />
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div class="main-block">
<h1>Email verification</h1>
<form action="" method="post">
<input type="email" name="email_id" id="email_id" placeholder="Email" required class="form-control"/>
<b class="text-<?php echo $className; ?>"><?php echo $msgSend; ?></b><br>
<button class="btn btn-lg btn-primary btn-block" type="submit" name="verifyMail" id="verifyMail">
Verify email
</button>
</form>
<div style="padding: 20px;">
<table class="table table-hover">
<thead>
<tr>
<th>Email</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php
$selectQuery = "SELECT * FROM email_list";
$fetch = mysqli_query($connection, $selectQuery);
while ($row = mysqli_fetch_assoc($fetch)) {
?>
<tr>
<td>
<?php
echo $row['email_id'];
?>
</td>
<td>
<?php
echo $row['status'] == 0 ? "Not verified" : "Verified";
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</html>