<?php
include "auth.php";
include "db.php";


$id = $_GET['id'];    
$pid = $_GET['pid'];  


$result = $conn->query("SELECT * FROM product_images WHERE id=$id");
$image = $result->fetch_assoc();

if ($image) {

    $filePath = "../uploads/" . $image['image_path'];

   
    if (file_exists($filePath)) {
        unlink($filePath);
    }

   
    $conn->query("DELETE FROM product_images WHERE id=$id");
}


header("Location: editproducts.php?id=$pid");
exit();
?>