<?php
//include constants files
  include('../config/constants.php');
  //check whether the id and image_name value is set or not
  if (isset($_GET['id'])) {
    // get the value and delete
    //echo "get data";
    $id= $_GET['id'];

    // remove the physical image file if is avalaible

    //delete data frm db
    //sql query to delete data frm db
    $sql = "DELETE FROM tbl_category WHERE id=$id";
    //execute the query
    $res = mysqli_query($conn, $sql);
    //check whether the data is deleted frm the db or not
    if ($res==true) {
      // redirect to the manage category with a success msg
      $_SESSION['delete'] = "<div class='success'>Category Deleted Successfully.</div>";
      header('location:'.SITEURL.'backend/manage-category.php');
    }else{
      //redirect to manage category with error msg
      $_SESSION['delete'] = "<div class='error'>Failed to Delete the Category .</div>";
      header('location:'.SITEURL.'backend/manage-category.php');
    }
    //redirect to manage category page with a msg

  }else{
    //redirect to the manage-category page
    header('location:'.SITEURL.'backend/manage-category.php');
  }
 ?>
