Merge branch 'main' of https://git.bruschetta.cc/andrea/php-school
This commit is contained in:
commit
66136e964f
4 changed files with 35 additions and 25 deletions
|
@ -7,21 +7,19 @@
|
||||||
<td>Voto</td>
|
<td>Voto</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
$voti = array("Piero"=>3, "Paolo"=>9, "Luca"=>7, "Roberto"=>3);
|
$voti = ["Piero" => 3, "Paolo" => 9, "Luca" => 7, "Roberto" => 3];
|
||||||
$media = 0;
|
$media = 0;
|
||||||
foreach($voti as $name => $voto){
|
foreach ($voti as $name => $voto) {
|
||||||
$media+= $voto;
|
$media += $voto;
|
||||||
echo "<tr>
|
echo "<tr>
|
||||||
<td>$name</td>
|
<td>$name</td>
|
||||||
<td>$voto</td>
|
<td>$voto</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
$media = $media / count($voti);
|
$media = $media / count($voti);
|
||||||
?>
|
?>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<?php
|
<?php echo $media; ?>
|
||||||
echo $media;
|
|
||||||
?>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -13,20 +13,19 @@ if (!isset($_COOKIE["votiFemminili"])) {
|
||||||
if (!isset($_COOKIE["votiMaschili"])) {
|
if (!isset($_COOKIE["votiMaschili"])) {
|
||||||
setcookie("votiMaschili", 0, time() + 60 * 60 * 24 * 30);
|
setcookie("votiMaschili", 0, time() + 60 * 60 * 24 * 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<html lang="it">
|
<html lang="it">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Login</title>
|
<title>Login</title>
|
||||||
<?php require "includes/head.php" ?>
|
<?php require "includes/head.php"; ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1>Vota Atleti</h1>
|
<h1>Vota Atleti</h1>
|
||||||
<h2>Ciao <?php echo $_SESSION["nome"] ?></h2>
|
<h2>Ciao <?php echo $_SESSION["nome"]; ?></h2>
|
||||||
<form action="thanks.php" method="post">
|
<form action="thanks.php" method="post">
|
||||||
<?php
|
<?php
|
||||||
$nomi = [];
|
$nomi = [];
|
||||||
|
@ -38,16 +37,24 @@ if (!isset($_COOKIE["votiMaschili"])) {
|
||||||
|
|
||||||
foreach ($nomi as $nome) {
|
foreach ($nomi as $nome) {
|
||||||
echo '<div class="mb-3">';
|
echo '<div class="mb-3">';
|
||||||
echo '<label for="voto_' . $nome . '" class="form-label">' . $nome . '</label>';
|
echo '<label for="voto_' .
|
||||||
echo '<input type="number" class="form-control" id="voto_' . $nome . '" name="voto_' . $nome . '" min="1" max="10">';
|
$nome .
|
||||||
echo '</div>';
|
'" class="form-label">' .
|
||||||
|
$nome .
|
||||||
|
"</label>";
|
||||||
|
echo '<input type="number" class="form-control" id="voto_' .
|
||||||
|
$nome .
|
||||||
|
'" name="voto_' .
|
||||||
|
$nome .
|
||||||
|
'" min="1" max="10">';
|
||||||
|
echo "</div>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<button type="submit" class="btn btn-primary">Invia voti</button>
|
<button type="submit" class="btn btn-primary">Invia voti</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php require "includes/footer.php" ?>
|
<?php require "includes/footer.php"; ?>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
global $votes;
|
global $votes;
|
||||||
include "includes/security.php";
|
include "includes/security.php";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
|
@ -9,7 +8,7 @@ include "includes/security.php";
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Login</title>
|
<title>Login</title>
|
||||||
<?php require "includes/head.php" ?>
|
<?php require "includes/head.php"; ?>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -21,7 +20,7 @@ include "includes/security.php";
|
||||||
<canvas id='statisicheBrowser'></canvas>
|
<canvas id='statisicheBrowser'></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php require "includes/footer.php" ?>
|
<?php require "includes/footer.php"; ?>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -35,7 +34,9 @@ include "includes/security.php";
|
||||||
labels: ['Pellegrini', 'Egonu', 'Vio'],
|
labels: ['Pellegrini', 'Egonu', 'Vio'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: '# of Votes',
|
label: '# of Votes',
|
||||||
data: [<?= $votes["voto_Pellegrini"] ?>, <?= $votes["voto_Egonu"] ?>, <?= $votes["voto_Vio"] ?>,],
|
data: [<?= $votes["voto_Pellegrini"] ?>, <?= $votes[
|
||||||
|
"voto_Egonu"
|
||||||
|
] ?>, <?= $votes["voto_Vio"] ?>,],
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
@ -55,7 +56,9 @@ include "includes/security.php";
|
||||||
labels: ['Totti', 'Tamberi', 'Rossi'],
|
labels: ['Totti', 'Tamberi', 'Rossi'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: '# of Votes',
|
label: '# of Votes',
|
||||||
data: [<?= $votes["voto_Totti"] ?>, <?= $votes["voto_Tamberi"] ?>, <?= $votes["voto_Rossi"] ?>,],
|
data: [<?= $votes["voto_Totti"] ?>, <?= $votes[
|
||||||
|
"voto_Tamberi"
|
||||||
|
] ?>, <?= $votes["voto_Rossi"] ?>,],
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
@ -74,7 +77,9 @@ include "includes/security.php";
|
||||||
labels: ['Maschi', 'Femmine'],
|
labels: ['Maschi', 'Femmine'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: '# of Votes',
|
label: '# of Votes',
|
||||||
data: [<?= $_COOKIE["votiMaschili"] ?>, <?= $_COOKIE["votiFemminili"] ?>],
|
data: [<?= $_COOKIE["votiMaschili"] ?>, <?= $_COOKIE[
|
||||||
|
"votiFemminili"
|
||||||
|
] ?>],
|
||||||
borderWidth: 1
|
borderWidth: 1
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"voto_Pellegrini":20,"voto_Egonu":20,"voto_Vio":20,"voto_Totti":16,"voto_Tamberi":17,"voto_Rossi":13}
|
{"voto_Pellegrini":30,"voto_Egonu":30,"voto_Vio":30,"voto_Totti":17,"voto_Tamberi":19,"voto_Rossi":16}
|
Loading…
Add table
Reference in a new issue