Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

Webserver1/Ovningar/Quiz/

account.php
create_quiz.js
create_quiz.php
fetch_table.php
frontpage.php
header.php
login.php
quiz.php
quiz_answer_finished.php
quiz_creation_finished.php
signup.php
style.css

frontpage.php

77 lines ASCII Windows (CRLF)
<?php
session_start
();
include(
'../../incl/dbconnection.php');

// Program to display complete URL
$link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']
  === 
'on' "https" "http") . "://" .
  
$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

// Display the complete URL
$_SESSION['lastVisited'] = $link;
/**
 * @var PDO $dbconn
 */

// show all error reporting
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

include('header.php');
$getQuizzes "SELECT
  q.quiz_id,
  q.quiz_name,
  q.creation_date,
  q.is_active,
  q.total_views,
  u.username AS creator_name
  FROM quiz_quizzes q
  JOIN quiz_users u ON q.creator_id = u.user_id
  WHERE q.is_active = TRUE
  ORDER BY q.total_views
  LIMIT 20"
;
$getStmt $dbconn->prepare($getQuizzes);
$getStmt->execute();
$getResult $getStmt->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html lang="sv">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Quiz Cross</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div id="frontpage-card-container">
    <?php

    
foreach ($getResult as $i => $row): ?>
      <div class="card">
        <a href="quiz.php?quiz_id=<?php echo $row["quiz_id"?>">
          <h3><?php echo $row["quiz_name"?></h3>
          <div class="row">
            <div class="center-container">
              <img src="../../Media/ikoner/person_black.svg" alt="">
              <p>
                <?php echo $row["creator_name"?>
              </p>
            </div>
            <div class="center-container">
              <img src="../../Media/ikoner/eye_black.svg" alt="">
              <p>
                <?php echo $row["total_views"?>
              </p>
            </div>
          </div>
        </a>
  </div>
<?php endforeach; ?>
</div>
</body>

</html>