diff --git a/similverifica_votazioni_atleti/includes/security.php b/similverifica_votazioni_atleti/includes/security.php index a6a0d8b..dca2cc4 100644 --- a/similverifica_votazioni_atleti/includes/security.php +++ b/similverifica_votazioni_atleti/includes/security.php @@ -1,19 +1,47 @@ 0, + "Egonu" => 0, + "Vio" => 0, + "Totti" => 0, + "Tamberi" => 0, + "Rossi" => 0 + ]; + file_put_contents("votes.json", json_encode($votes)); + } + +} + function checkPost() { unset($_SESSION["error"]); if (empty($_POST["nome"]) || empty($_POST["eta"]) || empty($_POST["sesso"])) { $_SESSION["error"] = "Dati mancanti"; + header("Location: login.php"); + exit(); } if ($_POST["eta"] < 18) { $_SESSION["error"] = "Devi avere 18 anni per entrare"; + header("Location: login.php"); + exit(); } - header("Location: login.php"); - exit(); } function checkSession() @@ -32,11 +60,4 @@ function checkHasVoted() return false; } return true; -} - -function addVote($film, $vote) -{ - global $votes; - $votes[$film] += $vote; - file_put_contents("votes.json", json_encode($votes)); } \ No newline at end of file diff --git a/similverifica_votazioni_atleti/index.php b/similverifica_votazioni_atleti/index.php index 0652c8e..2eb0e3a 100644 --- a/similverifica_votazioni_atleti/index.php +++ b/similverifica_votazioni_atleti/index.php @@ -2,6 +2,17 @@ include "includes/security.php"; checkPost(); + +$_SESSION["nome"] = $_POST["nome"]; + +if (!isset($_COOKIE["votiFemminili"])) { + setcookie("votiFemminili", 0, time() + 60 * 60 * 24 * 30); +} + +if (!isset($_COOKIE["votiMaschili"])) { + setcookie("votiMaschili", 0, time() + 60 * 60 * 24 * 30); +} + ?> @@ -16,26 +27,23 @@ checkPost();