<?php 

$dir = '../../';

require_once $dir.'includes/main.php';

$errors = array();

$id = (int)$_GET['id'];

$sql = "SELECT * FROM categories WHERE id = '{$id}' LIMIT 1";
if(fetch_rows($sql) < 1){
    $errors[] = "Category could not be found";
}else{
    $x = fetch_records($sql);
}

//check errors
if(!empty($errors)){

    $_SESSION['messages'] = $errors;

}else{

    // on success
    delete_category($id);
    $_SESSION['messages'][] = "Records has been deleted successfully";

}

header("location: ../settings/categories");
exit;

?>