TKK_E32230607/smart-drop-point/public/hapus_log.php

26 lines
693 B
PHP

<?php
require_once __DIR__ . "/../config/db.php";
$id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
if ($id > 0) {
$q = $conn->query("SELECT foto_path FROM log_akses WHERE id = {$id} LIMIT 1");
if ($q && $q->num_rows > 0) {
$data = $q->fetch_assoc();
if (!empty($data['foto_path'])) {
$relativePath = ltrim($data['foto_path'], '/');
$fullPath = dirname(__DIR__) . '/' . $relativePath;
if (file_exists($fullPath) && is_file($fullPath)) {
unlink($fullPath);
}
}
$conn->query("DELETE FROM log_akses WHERE id = {$id}");
}
}
header("Location: /smart-drop-point/public/log.php");
exit;