<?php
session_start();
header('Content-Type: application/json');
include '../config/database.php';
$db = new Database();
$conn = $db->getConnection();

$id = $_POST['id'];
// Hapus foto
$stmt = $conn->prepare("SELECT foto_gereja FROM gereja WHERE id=?");
$stmt->execute([$id]);
$foto = $stmt->fetchColumn();
if($foto != 'gereja.png') @unlink('../assets/img/gereja/'.$foto);

$conn->prepare("DELETE FROM gereja WHERE id=?")->execute([$id]);
echo json_encode(['status'=>'success','message'=>'Data gereja dihapus']);
?>