-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.php
More file actions
86 lines (74 loc) · 2.82 KB
/
verify.php
File metadata and controls
86 lines (74 loc) · 2.82 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
<?php
require_once 'connection.php';
$success = "";
$error = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$code = trim($_POST['code']);
$stmt = $con->prepare("SELECT * FROM users WHERE verification_code = ?");
$stmt->bind_param("s", $code);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 1) {
$user = $result->fetch_assoc();
if ($user['is_verified'] == 0) {
$update = $con->prepare("UPDATE users SET is_verified = 1 WHERE verification_code = ?");
$update->bind_param("s", $code);
if ($update->execute()) {
// Optionally, you can log in the user here or redirect to dashboard
header("Location: profile.php");
exit;
} else {
$error = "Something went wrong. Please try again.";
}
$update->close();
} else {
$success = "Your email is already verified.";
}
} else {
$error = "Invalid verification code.";
}
$stmt->close();
}
$con->close();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verify Email | FinTrack</title>
<link rel="icon" href="img/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 min-h-screen flex items-center justify-center">
<div class="w-full max-w-md bg-white p-8 rounded shadow-md">
<div class="flex justify-center mb-6">
<img class="w-48" src="img/powered.png" alt="Logo" />
</div>
<?php if (!empty($success)): ?>
<div class="mb-4 text-green-600 text-center font-medium">
<?= htmlspecialchars($success) ?>
</div>
<?php endif; ?>
<?php if (!empty($error)): ?>
<div class="mb-4 text-red-600 text-center font-medium">
<?= htmlspecialchars($error) ?>
</div>
<?php endif; ?>
<form method="POST" class="space-y-4">
<label class="block">
<span class="text-gray-700">Verification Code</span>
<input type="text" name="code" maxlength="6" required
class="mt-1 block w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-[#1bb34c]">
</label>
<button type="submit"
class="w-full bg-[#1bb34c] text-white py-2 rounded hover:bg-green-700 transition">
Verify Email
</button>
</form>
<div class="mt-6 text-center">
<a href="login.php" class="text-[#1bb34c] hover:underline">Back to Login</a>
</div>
</div>
</body>
</html>