second commit

This commit is contained in:
Bildcraft1 2024-10-31 11:31:27 +01:00
parent d975e212f9
commit 12d8e33009
9 changed files with 266 additions and 0 deletions

View file

@ -0,0 +1,42 @@
<?php
session_start();
function checkPost()
{
unset($_SESSION["error"]);
if (empty($_POST["nome"]) || empty($_POST["eta"]) || empty($_POST["sesso"])) {
$_SESSION["error"] = "Dati mancanti";
}
if ($_POST["eta"] < 18) {
$_SESSION["error"] = "Devi avere 18 anni per entrare";
}
header("Location: login.php");
exit();
}
function checkSession()
{
if (empty($_SESSION["nome"]) || empty($_SESSION["code"]) || empty($_SESSION["film"]) || empty($_SESSION["voto"])) {
$_SESSION["error"] = true;
header("Location: login.php");
exit();
}
}
function checkHasVoted()
{
if (isset($_COOKIE["hasVoted"]) && $_COOKIE["hasVoted"]) {
$_SESSION["error"] = true;
return false;
}
return true;
}
function addVote($film, $vote)
{
global $votes;
$votes[$film] += $vote;
file_put_contents("votes.json", json_encode($votes));
}