У меня есть форма, которая передает идентификатор, который необходимо записать в сеанс.
Он не изменяется.$id = $ _SESSION ['id']; // this is the error line:
Примечание: неопределенный индекс: id в C: \ wamp \ www \ project \ database \ update.php в строке 5
editar.php
<?php
include_once 'banco_de_dados/conexao.php';
$id = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT);
$_SESSION['id'] = $id;
$querySelect = $link->query("select * from tb_clientes where id='$id'");
while($registros = $querySelect->fetch_assoc()):
$nome = $registros['nome'];
$email = $registros['email'];
$telefone = $registros['telefone'];
endwhile;
?>
<!-- Formulário de Cadastro-->
<p> </p>
<form action="banco_de_dados/update.php" method="post" class="col s12">
<fieldset class="formulario" style="padding:15px;">
<legend><img src="assets/img/logo.png"></legend>
<h5 class="light center">Alteração de Clientes</h5>
<!-- Campo Nome -->
<div class="input-field col s12">
<i class="material-icons prefix">account_circle</i>
<input type="text" name="nome" id="nome" value="<?php echo $nome ?>" maxlength="40" required autofocus>
<label for="nome">Nome do Cliente</label>
</div>
<!-- Campo Email -->
<div class="input-field col s12">
<i class="material-icons prefix">email</i>
<input type="email" name="email" id="email" value="<?php echo $email ?>" maxlength="50" required autofocus>
<label for="email">Email do Cliente</label>
</div>
<!-- Campo Telefone -->
<div class="input-field col s12">
<i class="material-icons prefix">phone</i>
<input type="tel" name="telefone" id="telefone" value="<?php echo $telefone ?>" maxlength="15" required autofocus>
<label for="telefone">Telefone do Cliente</label>
</div>
<!-- Botoes -->
<div class="input-field col s12">
<input type="submit" value="alterar" class="btn blue">
<a href="consultas.php" class="btn red">cancelar</a>
</div>
</fieldset>
</form>
</div>
update.php
<?php
session_start();
include_once 'conexao.php';
$id = $_SESSION['id']; // essa é a linha do erro
$nome = filter_input(INPUT_POST, 'nome', FILTER_SANITIZE_SPECIAL_CHARS);
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
$telefone = filter_input(INPUT_POST, 'telefone', FILTER_SANITIZE_NUMBER_INT);
$queryUpdate = $link->query("update tb_clientes set nome='$nome', email='$email', telefone='$telefone' where id='$id'");
$affected_rows = mysqli_affected_rows($link);
if($affected_rows > 0):
header("Location:../consultas.php");
endif;