<?php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
   
   include('connection.php');
 
   
    $title = $_POST["title"];
    $discription = $_POST["discription"];
    $qty = $_POST["qty"];
    $amount = $_POST["amount"];
    $currentDateTime = date('Y-m-d H:i:s');

    
    $sql = "INSERT INTO expenses (title,discription, quantity, amount,datetime) VALUES ('$title','$discription', '$qty', '$amount','$currentDateTime')";
    
  
    if ($conn->query($sql) === TRUE) {
        header("Location: expenses.php?success=Expense Added Successfully!!!");
        exit(); 
    } else {
        echo "Error: " . $sql . "<br>" . $conn->error;
    }

   
    $conn->close();
}
?>