<?php
include '../config/db.php';

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $method_id = $_POST['method_id'];
    $method_name = htmlspecialchars(trim($_POST['method_name']));

    try {
        $stmt = $pdo->prepare("UPDATE payment_methods SET method_name = :method_name WHERE id = :id");
        $stmt->execute(['method_name' => $method_name, 'id' => $method_id]);
        header("Location: add_payment_method.php?success=Payment method updated successfully");
    } catch (PDOException $e) {
        die("Error updating payment method: " . $e->getMessage());
    }
}
?>
