0
How to print my array this way:
NAME|TELEPHONE|EMAIL|FAVORITE DATE OF BIRTH|DESCRIPTION
I can only print by columns
follows the code
<!DOCTYPE html>
<?php session_start(); ?>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Lista de Contatos</title>
</head>
<body>
<form>
<fieldset>
<legend>Lista de Contatos</legend>
Nome<br>
<input type="text" name="nome">
<br>
Telefone<br>
<input type="tel" name="telefone">
<br>
Email<br>
<input type="email" name="email">
<br>
Data de nascimento<br>
<input type="date" name="dataNascimento">
<br>
Favorito <input type="checkbox" name="vip" value="Favorito">
<br>
Descrição<br>
<textarea name="descricao" rows="10" cols="30">
</textarea>
<br>
<input type="submit" value="Cadastrar">
</fieldset>
</form>
<?php
if(isset($_GET['nome'])){
$_SESSION['l1'][] = $_GET['nome'];
}
if(isset($_GET['telefone'])){
$_SESSION['l1'][] = $_GET['telefone'];
}
if(isset($_GET['email'])){
$_SESSION['l1'][] = $_GET['email'];
}
if(isset($_GET['dataNascimento'])){
$_SESSION['l1'][] = $_GET['dataNascimento'];
}
if(isset($_GET['vip'])){
$_SESSION['l1'][] = $_GET['vip'];
}
if(isset($_GET['descricao'])){
$_SESSION['l1'][] = $_GET['descricao'];
}
if(isset($_SESSION['l1'])){
$lista_contatos = array();
$lista_contatos = $_SESSION['l1'];
?>
<table border="1">
<tr>
<th colspan="6">Contatos Cadastrados</th>
</tr>
<tr>
<td>Nome</td>
<td>Telefone</td>
<td>Email</td>
<td>Data de Nascimento</td>
<td>Favorito</td>
<td>Descrição</td>
</tr>
<?php foreach($lista_contatos as $contatos) : ?>
<tr>
<td><?php echo $contatos; ?></td>
<?php endforeach?>
</table>
<?php } ?>
</body>
</html>
I don’t understand your answer, there’s only code?
– Wallace Maxters