Show sourcecode
The following files exists in this folder. Click to view.
webbserverprogrammering/submissions/projekt-matkort-handler/
.github/
add_logs.php
admin/
api/
card_balance.php
classes/
config/
food_logs.php
forgot_password.php
includes/
index.php
insert_restaurants.php
install.php
login.php
logout.php
public/
register.php
reset_password.php
verify.php
verify.php
58 lines UTF-8 Windows (CRLF)
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
<?php
session_start();
include_once './config/database.php';
include_once './classes/User.php';
$error = '';
$success = '';
if (isset($_GET['token'])) {
$token = htmlspecialchars($_GET['token']);
try {
$user_id = User::verifyEmail($pdo, $token);
// At this point verification was successful, mark session so they are logged in automatically
$stmt = $pdo->prepare("SELECT id, name, email FROM students WHERE id = ?");
$stmt->execute([$user_id]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
session_regenerate_id(true);
$_SESSION['user_id'] = $user['id'];
$_SESSION['name'] = $user['name'];
$_SESSION['email'] = $user['email'];
$_SESSION['logged_in'] = true;
$success = "Tack för att du bekräftade din e-post! Registreringen är klar och du plockas snart vidare till din profil...";
header("Refresh: 3; url=index.php");
} catch (Exception $e) {
$error = $e->getMessage();
}
} else {
$error = "Ingen giltig verifieringstoken fanns i länken.";
}
$page_title = 'Verifierar e-post';
require_once './includes/header.php';
?>
<div class="container">
<div class="login-box">
<h1>Verifiering</h1>
<?php if ($error): ?>
<div class="error-message">
<?php echo htmlspecialchars($error); ?>
<br><br><a href="login.php" class="btn btn-secondary">Tillbaka till inloggning</a>
</div>
<?php endif; ?>
<?php if ($success): ?>
<div class="success-message">
<?php echo htmlspecialchars($success); ?>
</div>
<?php endif; ?>
</div>
</div>
<?php require_once './includes/footer.php'; ?>