Help with deleting log

0

I have my exclude employee but give these errors:

"Undefined index: id in C: \ wamp \ www \ SitePHP \ base \ deleteFuntionary.php on line 6"

"PDO :: exec () expects parameter 1 to be string, object given in C: \ wamp \ www \ SitePHP \ base \ deleteFuntionary.php on line 8".

Follow my code:

require_once '../base/conexao.php';
$id = $_GET['id'];
$delete = $PDO->query("DELETE  FROM funcionario WHERE id = '$id' ");
$PDO->exec($delete);
if ($id){
    echo "<script>alert('Registro de Funcionario deletado');location.href = 'listarFuncionario.php';  </script>";
}else{
    echo "<script>alert('Ocorreu um erro no processo');location.href = 'listarFuncionario.php';  </script>";
}

function excluir(id){
    if(confirm("Deseja excluir o registro?")){
        location.href = 'excluirFuncionario.php';
        
    }
}
<?php while($funcionario = $rs->fetch(PDO::FETCH_ASSOC)) { ?>
    <tr>
    <td align="center"><a href="excluirFuncionario.php" onkeyup="excluir(id)" onclick="excluir(<?php echo $funcionario['id'];?>)"><img src="../imagens/delete.png"></a></td>
         </tr>
         <?php }?>
</tbody>
    
asked by anonymous 21.11.2017 / 14:35

1 answer

1

You are not passing the ID on the URL ... Try this:

function excluir(id){
    if(confirm("Deseja excluir o registro?")){
        location.href = 'excluirFuncionario.php?id=' + id;

    }
}

<?php while($funcionario = $rs->fetch(PDO::FETCH_ASSOC)) { ?>
    <tr>
    <td align="center"><a href="#" onclick="excluir(<?php echo $funcionario['id'];?>)"><img src="../imagens/delete.png"></a></td>
         </tr>
         <?php }?>
</tbody>
    
21.11.2017 / 15:17