prepare($sql); $stmt->execute([$expense_date, $description, $amount, $category]); // Redirect back to the expenses page with a success message header("Location: expenses.php?success=1"); exit(); } catch (PDOException $e) { // Handle error, maybe redirect with an error message header("Location: expenses.php?error=" . urlencode($e->getMessage())); exit(); } } else { // Handle invalid input header("Location: expenses.php?error=invalid_input"); exit(); } } ?>