Show sourcecode
The following files exists in this folder. Click to view.
css/
dashboard.php
inc/
index.php
js/
login.php
logout.php
profile.php
quizzes.php
register.php
results.php
index.php
89 lines UTF-8 Windows (CRLF)
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/* =========================
Grundläggande includes:
konfiguration, databas
och databasfunktioner
========================= */
include("inc/config.php");
include("inc/connect_db.php");
include("inc/db_manager.php");
/* =========================
Inloggningskontroll i
"loose"-läge (tillåter
även oinloggade besökare)
========================= */
$mode = "loose";
include("inc/login_check.php");
/* =========================
Sidtitel
========================= */
$page_title = "Quizzeria";
?>
<!DOCTYPE html>
<html lang="sv">
<?php include("inc/head.php"); ?>
<body>
<?php include("inc/header.php"); ?>
<!-- =========================
Topplista: 10 bästa spelare
========================= -->
<h2>10 Bästa spelare</h2>
<table>
<tr>
<th>Användare</th>
<th>Poäng</th>
</tr>
<?php
// Hämta alla användare (förväntas vara sorterade på poäng)
$users = getUsers($conn);
$counter = 0;
// Visa max 10 användare
foreach ($users as $user) {
if ($counter++ >= 10) {
break;
}
echo "<tr>";
echo "<td>" . htmlspecialchars($user['username']) . "</td>";
echo "<td>{$user['points']}</td>";
echo "</tr>";
}
?>
</table>
<!-- =========================
Lista alla tillgängliga quiz
========================= -->
<div>
<h2>Välj ett quiz att spela</h2>
<?php
// Hämta alla quiz
$quizzes = getQuizzes($conn);
foreach ($quizzes as $quiz) {
echo "
<a class='quiz_card' href='quizzes.php?id={$quiz['id']}'>
{$quiz['title']}<br>
<p style='font-size: 15px;'>{$quiz['description']}</p>
</a><br>";
}
// Om inga quiz finns
if (count($quizzes) === 0) {
echo "<p><i>Inga quiz hittades</i></p>";
}
?>
</div>
<?php include("inc/footer.php"); ?>
</body>
</html>