<?php
session_start();
ob_start();
include "../include/config.php";

if (!isset($_SESSION['email'])) {
    header("Location: ../index.php");
    exit();
}

if (isset($_GET['id'])) {
    $id = intval($_GET['id']); 

    $delete = $conn->query("DELETE FROM balances WHERE id = '$id'");

    if ($delete) {
        header("Location: balance.php?success1= Invoice Has been Deleted");
        exit();
    } else {
        header("Location: balance.php?error=Could not delete the record!");
        exit();
    }
} else {
    header("Location: balance.php");
    exit();
}
?>
