<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
include_once('_db.php');
// Check if the delete parameter is set
if (isset($_GET['delete'])) {
    $id = intval($_GET['delete']); // Convert id to integer for security
    
    // Prepare and execute the delete query
    $sql = $conn->prepare("DELETE FROM wallet WHERE id = ?");
    $sql->bind_param("i", $id);
    
    if ($sql->execute()) {
        // If deletion was successful, redirect with a success message
        header("Location: manage-wallet.php?message=Wallet deleted successfully");
    } else {
        // If there was an error, redirect with an error message
        header("Location: manage-wallet.php?error=Unable to delete wallet");
    }
    $sql->close();
} else {
    // If no delete parameter is set, redirect back with an error message
    header("Location: manage-wallet.php?error=Invalid request");
}
?>
