Webbserverprogrammering 1

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-extended/

26 filer

admin.php
confirm_account.php
create_account.php
create_quiz.php
css/
dbconnection.php
highscore.php
index.php
js/
logbook.php
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
plan.php
planering.txt
profile.php
projektrapport.txt
quizzes.php
resources/
result.php
send_email.php
session_variable_array_check.php

index.php

66 lines ASCII Windows (CRLF)
<?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['quizExtended'] = ['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['quizExtended']['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['quizExtended']['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['quizExtended']['admin']) {
  echo 
"You are an admin!";
  
?>
  <a href="admin.php">Administration page</a>
  <?php

 
}
}

?>
</main>

</body>
</html>