Silme Butonu
<td width="10"><button data-id="<?php echo $surucucek['kullanici_id']; ?>" name="kullancisil" type="button" class="btn btn-danger btn-sm sil">Sil</button></td>Script kodu
<script>
$(document).on('click' ,'.sil', function(){
var id = $(this).data('id');
var name = $(this).attr('name');
//alert (silinecekid);
Swal.fire({
title: 'Kullanıcı Silinecek!',
text: "Silmek istediğinize emin misiniz?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Evet, sil!',
cancelButtonText: 'İptal!',
closeOnConfirm: false
}).then(function(isConfirm) { if (isConfirm) {
$.ajax({
type: 'post',
url: 'webting/delete_all.php',
data: {"name":name},
success: function (data) {
if (data) {
veri=JSON.parse(data);
Swal.fire(veri.title,veri.message,veri.icon)
}
else {
veri=JSON.parse(data);
Swal.fire(veri.title,veri.message,veri.icon)
}
}
});
}
});
});
</script>Php dosyasıif(isset($_POST['kullancisil'])){
$kullaniciid = $_POST['kullanici_id'];
$select = $db->prepare("SELECT * FROM data_kullanici WHERE kullanici_id =?");
$select -> execute(array($kullaniciid));
$bul = $select->fetch(PDO::FETCH_ASSOC);
$resim = $bul["kullanici_resim"];
unlink("../$resim");
$sil=$db->prepare("DELETE FROM data_kullanici WHERE kullanici_id=:kullanici_id ");
$kontrol=$sil->execute(array(
'kullanici_id' => $kullaniciid
));
if($kontrol){
$data['icon']="success";
$data['title']="İşlem Başarılı";
$data['message']="Silme İşlemi Başarılı.";
echo json_encode($data);
exit;
}else{
$kayitol['icon']="error";
$kayitol['title']="Başarısız";
$kayitol['message']="Silme İşlemi Başarısız.";
echo json_encode($kayitol);
exit;
}
}