I'm creating a program that stores a person's tasks in an array, and shows them those tasks. But I have trouble showing tasks. I can not show the old jobs. Only the last task entered is displayed.
Code:
<?php session_start(); ?>
<html>
<head>
<title>Gerenciador de Tarefas</title>
</head>
<body>
<h1>Gerenciador de Tarefas</h1>
</br>
<form>
<fieldset>
<legend>Nova Tarefa</legend>
<label>
Tarefa:
<input type="text" name="nome"/>
</label>
<input type="submit" value="Cadastrar"/>
</fieldset>
</form>
<?php
if (isset($_GET['nome'])) {
$_SESSION['lista_tarefas'] = $_GET['nome'];
}
$lista_tarefas = array();
if (isset($_SESSION['lista_tarefas'])) {
$lista_tarefas = $_SESSION['lista_tarefas'];
}
?>
<table>
<tr>
<th>Tarefas</th>
</tr>
<?php foreach($lista_tarefas as $tarefa) : ?>
<tr>
<td><?php echo $tarefa ?> </td>
</tr>
<?php endforeach; ?>
</table>
</body>
</html>
Thank you for your attention!