-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfirm_email.php
More file actions
183 lines (158 loc) · 5.39 KB
/
Copy pathconfirm_email.php
File metadata and controls
183 lines (158 loc) · 5.39 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
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
<?php
/**
* Email Confirmation Page
*
* This script handles email confirmation for the lab management system.
* It verifies the email token from the URL, updates the user's email
* verification status, and displays an appropriate message.
*
*/
require 'dbcon.php'; // Include your database connection file
// Query to fetch the lab name from the settings table
$labQuery = "SELECT value FROM settings WHERE name = 'lab_name' LIMIT 1";
$labResult = mysqli_query($con, $labQuery);
// Default value if the query fails or returns no result
$labName = "My Vivarium";
if ($row = mysqli_fetch_assoc($labResult)) {
$labName = $row['value'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Confirmation | <?php echo htmlspecialchars($labName); ?></title>
<!-- Favicon and icons for different devices -->
<link rel="icon" href="/icons/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
<link rel="icon" sizes="192x192" href="/icons/android-chrome-192x192.png">
<link rel="icon" sizes="512x512" href="/icons/android-chrome-512x512.png">
<link rel="manifest" href="manifest.json" crossorigin="use-credentials">
<!-- Bootstrap and Google Font -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;700&display=swap" rel="stylesheet">
<style>
.container {
max-width: 900px;
margin-top: 50px;
margin-bottom: 50px;
padding: 20px;
border: 1px solid var(--bs-border-color);
border-radius: 5px;
background-color: var(--bs-tertiary-bg);
}
.btn {
display: block;
width: 100%;
padding: 10px;
border: none;
border-radius: 3px;
cursor: pointer;
}
.btn:hover {
background-color: #0056b3;
}
.note {
color: var(--bs-secondary-color);
font-size: 12px;
}
.header {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
background-color: var(--bs-dark);
color: var(--bs-white);
padding: 1rem;
text-align: center;
margin: 0;
}
.header .logo-container {
padding: 0;
margin: 0;
}
.header img.header-logo {
width: 300px;
height: auto;
display: block;
margin: 0;
}
.header h2 {
margin-left: 15px;
margin-bottom: 0;
margin-top: 12px;
font-size: 3.5rem;
white-space: nowrap;
font-family: 'Poppins', sans-serif;
font-weight: 500;
}
@media (max-width: 576px) {
.header h2 {
font-size: 1.8rem;
margin-bottom: 5px;
}
.header img.header-logo {
width: 150px;
}
.container {
max-width: 500px;
margin: 0 auto;
padding: 20px;
border: 1px solid var(--bs-border-color);
border-radius: 5px;
background-color: var(--bs-tertiary-bg);
}
}
</style>
</head>
<body>
<!-- Header Section -->
<?php if ($demo === "yes") include('demo/demo-banner.php'); elseif ($demo === "invite") include('demo/invite-banner.php'); ?>
<div class="header">
<div class="logo-container">
<a href="home.php">
<img src="images/logo1.jpg" alt="Logo" class="header-logo">
</a>
</div>
<h2><?php echo htmlspecialchars($labName); ?></h2>
</div>
<br>
<div class="container content">
<h2>Email Confirmation</h2>
<br>
<?php
if (isset($_GET['token'])) {
$token = $_GET['token'];
$stmt = $con->prepare("SELECT username FROM users WHERE email_token = ? AND email_verified = 0");
$stmt->bind_param("s", $token);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->bind_result($username);
$stmt->fetch();
$updateStmt = $con->prepare("UPDATE users SET email_verified = 1, email_token = NULL WHERE username = ?");
$updateStmt->bind_param("s", $username);
if ($updateStmt->execute()) {
echo "Email successfully confirmed. You can now <a href='index.php'>login</a>.";
} else {
echo "Error confirming email. Please try again.";
}
$updateStmt->close();
} else {
echo "Invalid or expired token.";
}
$stmt->close();
} else {
echo "No token provided.";
}
$con->close();
?>
<br>
</div>
<br>
<?php include 'footer.php'; ?>
</body>
</html>