I made a post for a question Login to PHP with Permission Levels which shows
as I should proceed with POST, Mysql, PDO, Mysqli, and filter_input for better security, but I've been following your example to understand input, form, and hidden relationship with PHP. It would be very cool after understanding how this exclusion happens, to follow the normalization of coding, as above link
The form should contain the text
or hidden
field with the value of the code you want to send to the PHP
script to perform the delete task via SQL
banco MySql
.
In the example I'm passing this form contains a hidden with id name with value of 1, then clicking the delete button will submit the form and execute the delete SQL
//Aqui o código id ta fixo (campo hidden)
<form action='deletar.php' method='post'>
<input type='hidden' name='id' value='1'>
<input type='submit' name='deletar' value='deletar' />
</form>
//Aqui você digita o código (campo text)
<form action='deletar.php' method='post'>
<input type='text' name='id' value=''>
<input type='submit' name='deletar' value='deletar' />
</form>
if (isset($_POST['id'] && is_numeric($_POST['id'])) {
$del = "DELETE FROM autoriza WHERE ID = " . $_POST['id'];
$delgo = mysql_query($del) or die('Erro ao deletar');
echo "deletado";
}