Show sourcecode
The following files exists in this folder. Click to view.
account.php
admin_register.php
create_quiz.php
create_tables.php
index.php
login.php
nav.css
nav.php
quiz.php
quiz_select.php
register.php
result_details.php
result_simple.php
submit_create_quiz.php
submit_quiz.php
account.php
40 lines UTF-8 Windows (CRLF)
<?php
session_start();
include ('../../incl/dbconnect.php');
// Kontrollera om användaren är inloggad
if (!isset($_SESSION['user_id'])) {
header('Location: login.php'); // Om ej inloggad skicka till login
exit();
}
// Hämta användarens data från databasen
$user_id = $_SESSION['user_id'];
$stmt = $dbconn->prepare("SELECT username, is_admin FROM users_quiz WHERE id = :id");
$stmt->bindParam(':id', $user_id, PDO::PARAM_INT);
$stmt->execute();
$user = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$user) {
echo "Användaren hittades inte.";
exit();
}
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mitt Konto</title>
<link rel="stylesheet" href="nav.css">
</head>
<body>
<?php include ('nav.php'); ?>
<h1>Mitt Konto</h1>
<p><strong>Användarnamn:</strong> <?php echo htmlspecialchars($user['username']); ?></p>
<p><strong>Administratör:</strong> <?php echo $user['is_admin'] ? 'Ja' : 'Nej'; ?></p>
</body>
</html>