<?php
include "includes/security.php";

checkPost();

$_SESSION["nome"] = $_POST["nome"];
$_SESSION["code"] = $_POST["code"];
$_SESSION["film"] = $_POST["film"];
$_SESSION["voto"] = $_POST["voto"];

?>
<!DOCTYPE HTML>
<html lang="it">

<head>
    <title>Login</title>
    <?php require "includes/head.php" ?>
</head>

<body>
<?php if (checkHasVoted()) { ?>
    <div class="container">
        <h1>Conferma Voto</h1>
        <h2>Nome utente: <?php echo $_SESSION["nome"] ?></h2>
        <h2>Film: <?php echo $_SESSION["film"] ?></h2>
        <h2>Voto: <?php echo $_SESSION["voto"] ?></h2>
        <form action="thanks.php" method="post">
            <div class="mb-3">
                <label for="nome" class="form-label">Vuoi confermare il voto?</label>
                <button type="submit" class="btn btn-primary">Invia voto</button>
            </div>
        </form>
    </div>
<?php } else { ?>
    <script>
        alert("Hai già votato, non puoi votare una seconda volta")
        window.location.href = "login.php"
    </script>
<?php } ?>

<?php require "includes/footer.php" ?>

</body>
</html>
