The template.php file:
HTML code:
<html>
...
<table border="3">
<tr>
<th>Tarefas</th>
<th>Descrição</th>
<th>Prazo</th>
<th>Prioridade</th>
<th>Concluída</th>
</tr>
<?php foreach($lista_tarefas as $tarefa){ ?>
<tr>
<td><?=$tarefa['nome'];?></td>
<td><?=$tarefa['descricao'];?></td>
<td><?=$tarefa['prazo'];?></td>
<td><?=$tarefa['prioridade'];?></td>
<td><?=$tarefa['concluida'];?></td>
</tr>
<?php } ?>
</table>
...
</html >
PHP code:
<?php
session_start();
if(isset($_GET['nome']) && $_GET['nome'] != ''){
$tarefa = array();
$tarefa["nome"] = $_GET["nome"];
if(isset($_GET['descricao'])){
$tarefa['descricao'] = $_GET["descricao"];
}else{
$tarefa['descricao'] = '';
}
if(isset($_GET["prazo"])){
$tarefa['prazo'] = $_GET['prazo'];
}else{
$tarefa['prazo'] = '';
}
$tarefa['prioridade'] = $_GET['prioridade'];
if(isset($_GET['concluida'])){
$tarefa['concluida'] = $_GET["concluida"];
}else{
$tarefa['concluida'] = '';
}
$_SESSION['lista_tarefas'] = array($tarefa);
}
include "template.php";
And in the part of view
Errors given:
Notice: Undefined variable: task_list in
Warning: Invalid argument supplied for foreach () in
Does anyone know how to display and not show these errors?