Pessoal, estou começando no PHP e adquiri um livro pra estudos porém, me deparei com a seguinte situação e não consigo achar solução para ela:
Tenho dois códigos:
template.php que possui o formulário de inserção de dados junto com um foreach;
tarefas.php que possui o código para gravar as entradas do formulário em um array, com include "template.php";
Estou usando o XAMPP, quando eu abro o formulário no navegador, aparece o erro:
Segue o código: taferas.php
<!-- PHP-->
<?php
session_start();
if(isset($_GET['nome'])){
$_SESSION['lista_tarefas'][]=$_GET['nome'];
}
if(isset($_SESSION['lista_tarefas'])){
$lista_tarefas = $_SESSION['lista_tarefas'];
//<!-- echo "Nome informado: ". $_GET['nome']; -->
} else{
$lista_tarefas = array();
}
include "template.php";
?>
----------------------- template.php
<!DOCTYPE html>
<html>
<head>
<title> Gerenciador de Tarefas</title>
<link rel= "stylesheet" href="tarefas.css" type="text/css"/>
</head>
<body>
<h1> Gerenciador de Tarefas</h1>
<!-- Teste -->
<form>
<fieldset>
<legend> Nova Tarefa</legend>
<label>
Tarefa:
<input type="text" name="nome">
</label>
<input type="submit" name="Cadastrar">
</fieldset>
</form>
<table>
<tr>
<th>Tarefas:</th>
</tr>
<?php foreach ($lista_tarefas as $tarefa): ?>
<tr>
<td> <?php echo $tarefa; ?> </td>
</tr>
<?php endforeach; ?>
</table>
<label>
Descrição (Opcional)
<textarea name= "descrição"></textarea>
</label>
<label>
Prazo (Opicional)
<input type="text" name="prazo"/>
</label>
<fieldset>
<legend>Prioridade:</legend>
<label>
<input type="radio" name= "prioridade" value="baixa" checked />
Baixa
<input type="radio" name= "prioridade" value="media" checked />
Média
<input type="radio" name= "prioridade" value="alta" checked />
Alta
</label>
<input type= "submit" value= "Cadastrar">
</body>
</html>