diff --git a/voti.php b/voti.php index da81eb1..8ca3333 100644 --- a/voti.php +++ b/voti.php @@ -14,15 +14,17 @@ class Voto{ $this->voto = $voto; } } -$file = fopen("data/voti.csv", "r") or die("Non riesco a leggere il file, controlla che esista"); $voti = []; - -fgets($file); -while (($linea = fgets($file)) !== false) { - $campi = explode(",", $linea); - array_push($voti, new Voto($campi[0], $campi[1], $campi[2], $campi[3], $campi[4])); +if(file_exists("data/voti.csv")){ + $file = fopen("data/voti.csv", "r"); + + fgets($file); + while (($linea = fgets($file)) !== false) { + $campi = explode(",", $linea); + array_push($voti, new Voto($campi[0], $campi[1], $campi[2], $campi[3], $campi[4])); + } + fclose($file); } -fclose($file); ?> @@ -36,7 +38,7 @@ fclose($file);
Torna alla pagina principale Nessun voto caricato"; } else{