<?php
session_start();

require_once 'core/classes.php';
require_once 'core/classes/user.php';
$user = new User($con, $_SESSION['user']);
if(!$user->isLoggedIn()) {
  header('location: /login');
  exit;
}

if(!isset($_GET["id"])) {
  header("Location: ?id=".$_SESSION['user']);
} else {
  $id = (int)$_GET["id"];
}
$q = $con->prepare("SELECT * FROM games WHERE id = :id");
$q->bindParam(':id',$id,PDO::PARAM_INT);
$q->execute();
$game = $q->fetch();
if(!$game) {
  header('location: /error?err=404');
  exit;
}
?>
<!DOCTYPE html>
<html data-bs-theme="dark">
<head>
<?php
$getitstarted = new PartyStarter;
$getitstarted->header();
?>
</head>
<title><?php echo htmlspecialchars($game["name"]); ?> | <?php echo $sitename; ?></title>
<body>
<h1>yes i am FUCKING AGAIN still not hired to make html</h1>
<h1>this game is called <?php echo htmlspecialchars($game["name"]); ?></h1>
<h1>with id <?php echo (int)htmlspecialchars($game["id"]); ?></h1>
<p>thats all i have to say</p>
</body>
</html>
