Mini Kabibi Habibi
Current Path : C:/xampp/htdocs/cid/system/ |
|
Current File : C:/xampp/htdocs/cid/system/delete_submitted_mista_report.php |
<?php
session_start();
@include 'include/config.php';
$page_title = "Delete Submitted MISTA Report";
if (isset($_GET['id'])) {
$report_id = intval($_GET['id']);
// Step 1: Get file path
$stmt = $conn->prepare("SELECT file_path FROM submitted_mista_reports WHERE id = ?");
$stmt->bind_param("i", $report_id);
$stmt->execute();
$stmt->bind_result($file_path);
$stmt->fetch();
$stmt->close();
// Step 2: Delete from DB
$stmt = $conn->prepare("DELETE FROM submitted_mista_reports WHERE id = ?");
$stmt->bind_param("i", $report_id);
if ($stmt->execute()) {
// Step 3: Delete the file if it exists
if ($file_path && file_exists($file_path)) {
unlink($file_path);
}
$_SESSION['success_message'] = "MISTA Report deleted successfully.";
} else {
$_SESSION['error_message'] = "Error deleting report: " . $stmt->error;
}
header("Location: submitted_mista_reports.php"); // Go back to reports list
exit();
} else {
$_SESSION['error_message'] = "Invalid request. Report ID not provided.";
header("Location: submitted_mista_reports.php");
exit();
}
?>