<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$admin = $_SESSION["admin_" . $dbname];
$series = $_SESSION["series_" . $dbname];
if (isset($_POST['id']) && isset($_POST['image'])) {
    $id = $_POST['id'];
    $image = $_POST['image'];

    mysqli_query($conn, "UPDATE chalmain SET `imgpath`='' WHERE vouchno=$id")or die(mysqli_error($conn));

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

    echo "Image deleted successfully.";
} else {
    echo "Invalid request.";
}