:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/www/kreative_crm/**
:: Editing File: portfolio_delete.php
<?php include 'config/db.php'; include 'check_login.php'; // ✅ Validate ID if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { header("Location: portfolio.php?msg=Invalid Portfolio ID"); exit; } $portfolio_id = intval($_GET['id']); // ✅ Fetch portfolio details $query = "SELECT p.img_name, w.section_name FROM portfolio_photos p JOIN work_sections w ON p.work_section_id = w.id WHERE p.id = $portfolio_id"; $result = mysqli_query($conn, $query); if (mysqli_num_rows($result) === 0) { header("Location: portfolio.php?msg=Portfolio not found"); exit; } $row = mysqli_fetch_assoc($result); $image_name = $row['img_name']; $section_name = strtolower(trim($row['section_name'])); $folder_name = preg_replace('/[^a-z0-9]+/', '_', $section_name); // ✅ Define image path $image_path = "uploads/portfolio/$folder_name/$image_name"; // ✅ Delete image file if it exists if (file_exists($image_path) && !empty($image_name)) { unlink($image_path); } // ✅ Delete record from database $delete_sql = "DELETE FROM portfolio_photos WHERE id = $portfolio_id"; if (mysqli_query($conn, $delete_sql)) { header("Location: portfolio.php?msg=Portfolio deleted successfully"); exit; } else { $error = urlencode(mysqli_error($conn)); header("Location: portfolio.php?msg=Error deleting portfolio: $error"); exit; } ?>