-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathverify.php
70 lines (63 loc) · 2.58 KB
/
verify.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
<?php
date_default_timezone_set('Asia/Bangkok'); // Set to GMT+7 (Bangkok timezone)
session_start();
require 'includes/db.php';
require 'config/config.php';
// Check if the token is present in the URL
if (isset($_GET['token'])) {
$token = $_GET['token'];
// Verify the token and mark the account as verified
$stmt = $pdo->prepare("SELECT * FROM users WHERE verification_token = :token");
$stmt->execute(['token' => $token]);
$user = $stmt->fetch();
if ($user) {
// Update the user's verification status
$stmt = $pdo->prepare("UPDATE users SET is_verified = 1, verification_token = NULL WHERE id = :user_id");
$stmt->execute(['user_id' => $user['id']]);
// Show a success message and provide a login link
$success_message = "Your email has been successfully verified! You can now log in.";
} else {
$error_message = "Invalid verification link.";
}
} else {
$error_message = "No verification token provided.";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Verification</title>
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="bg-light">
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card">
<div class="card-body">
<h2 class="text-center">Email Verification</h2>
<!-- Display success or error messages -->
<?php if (!empty($success_message)): ?>
<div class="alert alert-success">
<?php echo htmlspecialchars($success_message); ?>
</div>
<p class="text-center">
<a href="login.php" class="btn btn-primary">Go to Login</a>
</p>
<?php elseif (!empty($error_message)): ?>
<div class="alert alert-danger">
<?php echo htmlspecialchars($error_message); ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>