我正在使用 PHP 模式来确认从表中删除记录,但它不起作用。弹出模式即使变成提交也会出现,但不幸的是记录没有被删除。知道为什么无法完成此操作。请为我提供确切的解决方案,我能做些什么来解决问题。
<?php
if(isset($_POST['deletedata']))
{
$id = $_POST['delete_id'];
mysqli_query($db, "DELETE FROM gallery WHERE id=$id");
header("Location:gallery.php");
}
?>
<script>
$(document).ready(function() {
$(".deletebtn").on('click', function() {
$(".deletemodal").modal('show');
var deletedId = $(this).closest("tr").find(':first-child').text();
$("#delete_id").val(deletedId);
});
});
</script>
<!---POP Delete Modal --->
<div class="modal fade" id="deletemodal" class="deletemodal"role="dialog"
aria-hidden="true" ><div class="modal-dialog" >
<div class="modal-content"><div class="modal-header">
<button type="button" class="close"
data-dismiss="modal" aria-hidden="true">×</button>
<h2 class="modal-title">Delete Image</h2>
</div>
<form action="gallery.php" method="post" enctype="multipart/form-
data">
<div class="modal-body">
<input type="hidden" name="delete_id" id="delete_id">
<p>Are you sure you want to delete this image?</p>
</div>
<div class="modal-footer">
<button type="submit" style="margin-right:-5px;"
name="deletedata" class="btn btn-primary" >Yes</button>
<button type="button" style="margin-top:-2px;" class="btn
btn-default " data-dismiss="modal">No</button>
</div>
</form></div></div> </div>
慕村9548890
茅侃侃