I wanna make delete with confirmation modal, the code below (js) for calling the div where delete modal contains Delete button (class is btn-ok).
HTML :
<a href="" data-href="add_user.php?iduser=<?php echo $iduser; ?>" class="btn btn-xs btn-danger btn-rounded" data-toggle="modal" data-target="#delete">
<i class="fa fa-trash"></i></a>
<div class="modal fade" id="delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<center>
<div class="modal-header">
<h2><i class="fa fa-trash-o"></i> Konfirmasi Hapus Data</h2>
</div>
<div class="modal-body">Anda yakin menghapus data ini?</div>
</center>
<div class="modal-footer">
<center>
<button type="button" class="btn btn-default" data-dismiss="modal">Batalkan</button>
<a class="btn btn-danger btn-ok">HAPUS SEKARANG</a>
</center>
</div>
</div>
</div>
</div>
Javascript :
<script>
$('#delete').on('show.bs.modal', function(e) {
$(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href'));
});
</script>
PHP :
<?php
require('koneksi.php');
$iduser = $_GET['iduser'];
$sqldel = "UPDATE bf_user_santara SET deleted='1' WHERE iduser='$iduser'";
if (mysqli_query($con, $sqldel)) {
echo "Record deleted successfully";
//$_SESSION['sukseshapus'] = 1;
} else {
echo "Error deleting record: " . mysqli_error($con);
}
?>
But i dont know why, when the mysqli_query($con, $sqldel)) was executed, the page didnt show the message "Record deleted successfully", and i wanna the page reload to add_user.php, how to do that? I've already tried but didnt work for me. Thank you
Sorry for my bad english :)
P.s here i doing soft delete, so data on the database just changed deleted_id, and my query worked, just not working on that message & page reloading