-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray.php
80 lines (74 loc) · 2.28 KB
/
array.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Array</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Cadastro de Alunos</h1>
<div id="dados">
<form method="post">
<h2>Cadastrar Aluno</h2>
<label for="nome">Nome</label>
<input type="text" name="nome" id="nome">
<label for="idade">Idade</label>
<input type="number" name="idade" id="idade">
<label for="serie">Série</label>
<input type="number" name="serie" id="serie">
<label for="media">Média</label>
<input type="number" name="media" id="media">
<br><br>
<button class = "cad">Cadastrar</button>
<br>
</form>
<form method="post">
<button type="submit" name="limpar">Limpar Dados</button>
</form>
</div>
<div id="cad">
<h2>Alunos Cadastrados</h2>
<table>
<thead>
<tr>
<th>Nome</th>
<th>Idade</th>
<th>Série</th>
<th>Média</th>
</tr>
</thead>
</div>
<tbody>
<?php
session_start();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['limpar'])) {
session_destroy();
session_start();
}
else{
$nome = $_POST['nome'];
$idade = $_POST['idade'];
$serie = $_POST['serie'];
$media_final = $_POST['media'];
if (!isset($Alunos)) {
$Alunos = array();
}
$novoAluno = array($nome, $idade, $serie, $media_final);
$_SESSION['Alunos'][] = $novoAluno;
foreach ($_SESSION['Alunos'] as $linhas) {
echo "<tr>";
foreach ($linhas as $valor) {
echo "<td>$valor</td>";
}
echo "</tr>";
}
}
}
?>
</tbody>
</table>
</body>
</html>