I'm trying to perform UPDATE, but it gives the following error:
Notice: Undefined index: id in C: \ wamp \ www \ SitePHP \ base \ updateFuncionario.php on line 4. Follow my code
function
function atualizar(id){
if(confirm("Deseja atualizar o registro?")){
location.href = 'atualizarFuncionario.php?id=' + id;
}
}
log.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="css/estilo.css">
<script src="JS/func.js"></script>
<script src="JS/jquery-3.2.1.min.js"></script>
</head>
<body>
<p class="cab">ALTERAÇÃO DE FUNCIONÁRIOS</p>
<form action="base/atualizarFuncionario.php" method="POST">
<?php
require_once './base/conexao.php';
$funcionario = filter_input(INPUT_GET,"id");
$nome_alter= filter_input(INPUT_GET,"nome");
$cpf_alter= filter_input(INPUT_GET,"cpf");
$tel_alter= filter_input(INPUT_GET,"tel");
?>
<center> <input type="text" id="inp" name="nome" size="40" value="<?php echo $nome_alter;?>" required="" placeholder="Nome" ><br><br>
<input type="text" name="cpf" id="inp" size="40" id="cpf" required="" value="<?php echo $cpf_alter;?>" maxlength="14" onkeyup="mascCPF(this.value)" placeholder="CPF xxx.xxx.xxx-xx"><br><br>
<input type="text" name="tel" id="inp" size="40" value="<?php echo $tel_alter;?>" id="tel" required="" maxlength="14" onkeyup="mascTel(this.value)" placeholder="Telefone(xx)9xxxx-xxxx"><br><br>
<a href="#" onclick="atualizar(<?php $funcionario = $_GET['id'];?>)"><button type="submit">ATUALIZAR</button></a></center>
</form>
<center> <a href="base/listarFuncionario.php"><input type="submit" value="Listar"</a> </center>
</body>
</html>
updateFunctional.php
include_once './conexao.php';
$id = $_GET['id'];
$nome = $_POST['nome'];
$cpf = $_POST['cpf'];
$telefone = $_POST['tel'];
$atualizar = "UPDATE funcionario SET nome='$nome', tel = '$telefone', cpf= '$cpf' WHERE id= '$id'";
$atualizar = $PDO->query($atualizar);
if($atualizar){
echo "<script>alert('Funcionario atualizado com sucesso!'); </script>";
} else {
echo "<script>alert('Erro ao atualizar'); </script>";
//location.href = '../formCadastro.php';
}