0
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 on the part of view
Given errors:
Notice: Undefined variable: lista_tarefas in
Warning: Invalid argument supplied for foreach() in
Does anyone know how to display and not show these errors?
@Nitroushang please delete the above comments to not pollute the site.
– Woss