37684-vm/verify.php
2026-03-01 00:04:22 +00:00

86 lines
4.1 KiB
PHP

<?php
session_start();
require_once 'db/config.php';
$project_name = $_SERVER['PROJECT_NAME'] ?? 'LPA Online';
$token = $_GET['token'] ?? '';
$error = '';
$success = '';
if (empty($token)) {
$error = 'Invalid verification link. No token provided.';
} else {
$db = db();
$stmt = $db->prepare('SELECT id, name FROM users WHERE verification_token = ?');
$stmt->execute([$token]);
$user = $stmt->fetch();
if ($user) {
$stmt = $db->prepare('UPDATE users SET is_verified = 1, verification_token = NULL WHERE id = ?');
if ($stmt->execute([$user['id']])) {
$success = "Welcome, " . htmlspecialchars($user['name']) . "! Your email has been successfully verified.";
} else {
$error = 'Something went wrong during verification. Please try again later or contact support.';
}
} else {
$error = 'Invalid or expired verification token.';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Verify Account — <?php echo htmlspecialchars($project_name); ?></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="assets/css/custom.css" rel="stylesheet">
</head>
<body class="bg-light d-flex flex-column min-vh-100">
<nav class="navbar navbar-expand-lg bg-white border-bottom shadow-sm">
<div class="container justify-content-center">
<a class="navbar-brand d-flex align-items-center m-0" href="/">
<img src="assets/pasted-20260228-235417-eedda424.png" alt="<?php echo htmlspecialchars($project_name); ?>" height="40">
</a>
</div>
</nav>
<main class="container py-5 flex-grow-1 d-flex align-items-center">
<div class="row justify-content-center w-100 m-0">
<div class="col-md-6 col-lg-5 text-center">
<div class="card shadow-lg border-0 p-4 p-md-5 rounded-4">
<?php if ($success): ?>
<div class="mb-4 text-success">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mb-3"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
<h1 class="h3 fw-bold">Verified!</h1>
<p class="text-muted small"><?php echo $success; ?></p>
</div>
<a href="login.php" class="btn btn-primary btn-lg w-100 rounded-pill">Sign In to Continue</a>
<?php else: ?>
<div class="mb-4 text-danger">
<svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="mb-3"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
<h1 class="h3 fw-bold">Verification Failed</h1>
<p class="text-muted small"><?php echo htmlspecialchars($error); ?></p>
</div>
<div class="row g-2">
<div class="col-6">
<a href="index.php" class="btn btn-outline-secondary btn-lg w-100 rounded-pill">Home</a>
</div>
<div class="col-6">
<a href="signup.php" class="btn btn-primary btn-lg w-100 rounded-pill">Try Again</a>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</main>
<footer class="py-4 text-center text-muted">
<div class="container">
<p class="small mb-0">&copy; <?php echo date('Y'); ?> <?php echo htmlspecialchars($project_name); ?>. All rights reserved.</p>
</div>
</footer>
</body>
</html>