31 lines
1.0 KiB
PHP
31 lines
1.0 KiB
PHP
<?php
|
|
require_once 'Database.php';
|
|
|
|
// Koneksi ke database
|
|
$pdo = Database::connect();
|
|
|
|
// Periksa jika ada permintaan penghapusan dan konfirmasi telah diberikan
|
|
if (isset($_GET['delete_id']) && isset($_GET['confirm']) && $_GET['confirm'] === 'true') {
|
|
$deleteId = $_GET['delete_id'];
|
|
$deleteStmt = $pdo->prepare("DELETE FROM tb_gabungan WHERE id = ?");
|
|
$deleteStmt->execute([$deleteId]);
|
|
|
|
// Redirect kembali ke halaman rekapdata atau halaman sebelumnya
|
|
header("Location: rekapdata.php");
|
|
exit();
|
|
} elseif (isset($_GET['delete_id'])) {
|
|
// Jika ada permintaan penghapusan, tampilkan dialog konfirmasi menggunakan JavaScript
|
|
echo '<script>
|
|
var confirmation = confirm("Data gabungan ini akan dihapus. Apakah Anda yakin?");
|
|
if (confirmation) {
|
|
window.location.href = "hapusgabungan.php?delete_id=' . $_GET['delete_id'] . '&confirm=true";
|
|
} else {
|
|
window.location.href = "rekapdata.php";
|
|
}
|
|
</script>';
|
|
}
|
|
|
|
// Tutup koneksi ke database
|
|
// Database::disconnect();
|
|
?>
|