Källkod
Följande filer och mappar finns under mappen webbserverprogrammering.
Mappar visas till vänster och filer till höger. Klicka på en fil eller mapp för att öppna nedan eller visa dess innehåll.
webbserverprogrammering/projects/quiz/
22 filer
admin.php
create_account.php
create_quiz.php
css/
dbconnection.php
hacktest.php
highscore.php
index.php
js/
login.php
mysql_create_table_options.php
mysql_create_table_questions.php
mysql_create_table_quizzes.php
mysql_create_table_results.php
mysql_create_table_submits.php
mysql_create_table_users.php
planering.txt
profile.php
quizzes.php
resources/
result.php
session_variable_array_check.php
create_account.php
create_quiz.php
css/
dbconnection.php
hacktest.php
highscore.php
index.php
js/
login.php
mysql_create_table_options.php
mysql_create_table_questions.php
mysql_create_table_quizzes.php
mysql_create_table_results.php
mysql_create_table_submits.php
mysql_create_table_users.php
planering.txt
profile.php
quizzes.php
resources/
result.php
session_variable_array_check.php
index.php
66 lines ASCII Windows (CRLF)
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
<?php
error_reporting(-1); // Report all type of errors
ini_set('display_errors', 1); // Display all errors
ini_set('output_buffering', 0); // Do not buffer outputs, write directly
function dump($dump) {
echo "<pre>";
var_dump($dump);
echo "</pre>";
}
session_start();
include "session_variable_array_check.php";
if (isset($_POST['logout'])) {
$_SESSION['quiz'] = ['loggedIn' => false, 'admin' => false, 'displayname' => "", 'userId' => 0, 'username' => ""];
}
?>
<!DOCTYPE html>
<html lang="sv">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta charset="utf-8">
<title>CuriousQuizzes</title>
</head>
<body>
<a href="index.php" id="logo">
CuriousQuizzes
</a>
<?php
if (!$_SESSION['quiz']['loggedIn']) { ?>
<h1>Welcome</h1>
<main>
<a href="quizzes.php">Quizzes</a><br>
<a href="login.php">Log in</a><br>
<a href="create_account.php">Create account</a>
<?php } else { ?>
<h1>Welcome <?= $_SESSION['quiz']['displayname'] ?></h1>
<main>
<a href="quizzes.php">Quizzes</a><br>
<a href="create_quiz.php">Create quiz</a><br>
<a href="profile.php">My profile</a><br>
<form method="post" action="">
<input type="submit" name="logout" value="Log out">
</form>
<?php
if ($_SESSION['quiz']['admin']) {
echo "You are an admin!";
?>
<a href="admin.php">Administration page</a>
<?php
}
}
?>
</main>
</body>
</html>