<?php
require_once "../config/db.php";

$id = (int) $_POST['id'];
$title = trim($_POST['title']);
$amount = $_POST['amount'];
$expense_date = $_POST['expense_date'];

if(!$id || empty($title) || !$amount || !$expense_date){
    die("Missing data");
}

$stmt = $conn->prepare("
UPDATE expenses SET 
title=?, 
amount=?, 
expense_date=? 
WHERE id=?
");

$stmt->bind_param("sdsi", $title, $amount, $expense_date, $id);
$stmt->execute();

header("Location: ../pages/expenses.php");
exit;
