I'd like to know what I can do to delete more than one client as selected by checkbox
. I have inside a complete form:
<form method="post" action="../sys/del.php">
<?php
require "../sys/conexao.php";
$sql = mysqli_query($mysqli, "SELECT * FROM contato");
while ($aux = mysqli_fetch_array($sql)) {
$id = $aux['id_contato'];
$nome = $aux['nome'];
$email = $aux['email'];
$assunto = $aux['assunto'];
$mes = $aux['mensagem'];
$hora = $aux['hora'];
print"
<tr>
<td><input type=\"checkbox\" name=\"valor[]\" id=\"$id\" value=\"$id\"/></td>
<td class=\"mailbox-star\"><a href=\"\"><i class=\"fa fa-star text-yellow\"></i></a></td>
<td class=\"mailbox-name\"><a href=\"read-mail.html\">$nome</a></td>
<td class=\"mailbox-subject\"><b>Kamilla Peliculas - Contato</b> - $assunto</td>
<td class=\"mailbox-attachment\"></td>
<td class=\"mailbox-date\">$hora</td>
</tr>";}
mysqli_close($mysqli);
?>
</tbody>
</table><!-- /.table -->
</div><!-- /.mail-box-messages -->
</div><!-- /.box-body -->
<div class="box-footer no-padding">
<div class="mailbox-controls">
<!-- Check all button -->
<div class="btn-group">
<button type="submit" name="excluir" class="btn btn-default btn-sm"><i class="fa fa-trash-o"></i></button>
</div>
</form>
And this form tells the page that it will get the value of these checkbox
selected and delete, however it gives the following error:
Notice: Undefined index: value in C: \ xampp \ htdocs \ new \ sys \ del.php on line 5
Warning: Invalid argument supplied for foreach () in C: \ xampp \ htdocs \ new \ sys \ del.php on line 5
Notice: Undefined variable: val in C: \ xampp \ htdocs \ new \ sys \ del.php on line 12
Someone can help me with this problem, I can not find the error.
PHP page code:
if(isset($_POST['excluir'])){
require_once"conexao.php";
foreach($_POST['valor'] as $ck){
$val = $v;
mysqli_query($mysqli, "DELETE FROM contato WHERE id_contato = '$val'");
echo"<script type=\"text/javascript\">alert(\"Campo Deletado Com Sucesso!\");
history.go(-1);</script>\n";
mysqli_close($mysqli);
}
}