Page in PHP connects to the bank, loads but does not shut down

0

Could you help me identify what's wrong with this code?

<?php
     include ("conexao.php");?>
     <?php
     $id = isset ($_POST['id']) ? $_POST['id']:'';
     $sql= "DELETE FROM 'guaxinim' WHERE 'guaxinim'.'id'=".$id;
     $result = mysqli_query($conn, $sql);
     if($result)
         die ("O registro foi excluído.");
      else
         echo "Infelizmente não foi possível excluir.";

    header('Location: cadastros.php');
?>

As the page loads when I take the "header" it appears that it worked and does not look like an error, but when I check the database the data is still there.

    
asked by anonymous 14.05.2018 / 03:38

1 answer

1

Since you are working with links with parameters) and not with form ( anchor ), you should use <form> instead of $_GET , eg

$id = isset ($_GET['id']) ? $_GET['id'] : '';

Do not forget to remove $_POST , otherwise echo will not work.

    
14.05.2018 / 03:45