<?php
include("connection.php");
if (isset($_POST['update'])) {
    $holder_name = $_POST['holder_name'];
    $bank_name = $_POST['bank_name'];
    $account_number = $_POST['account_number'];
    $ifsc_code = $_POST['ifsc_code'];
    $id = $_POST['id'];
    $payment_type = $_POST['payment_type'];
 


       
            // Update the existing record
            $updateQuery = "UPDATE bank_details SET payment_type = '$payment_type', holder_name = '$holder_name', account_number = '$account_number', ifsc_code = '$ifsc_code' WHERE id='$id'";
            $updateResult = mysqli_query($conn, $updateQuery);

            if ($updateResult) {
                header("Location: bank_details.php?msg=1"); // Updated successfully
                exit;
            } else {
                header("Location: bank_details.php?msg=2"); // Failed to update
                exit;
            }
    
        
    } else {
        header("Location: bank_details.php?msg=2"); // Failed to insert
        exit;
    }
?>
