I have a newsfeed where people can upload things, and on there I have a delete button. I read a few techniques you could do to delete a row from the database.
I used this one by using input type hidden field etc.
HTML
<form action="logic/delete_post.php" method="GET">
<input type="hidden" name="id" value="?id='.$pica['img_id'].'" />
<input type="submit" name="deleteSubmit" value="Delete" class="delete_post" />
</form>
DELETE_POST.PHP
<?php
if(isset($_GET['deleteSubmit'])) {
$img_id = substr($_GET['id'],4,6);
if(isset($_GET['id'])) {
$result = $mysqli->query("SELECT picas.img_id FROM picas WHERE username='$ses_user'");
$mysqli->query("DELETE FROM picas WHERE img_id='$img_id'");
if (mysqli_affected_rows() == 1) {
echo 'Succes!';
} else {
echo 'Damn!';
}
}
}
?>
Every comment with help is appreciated!