Viewing File: /home/quiczmwg/affordablerealtycorporation.com/admin/manage-wallet-process.php



  
<?php
session_start();
include_once("../_db.php");

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Get user input
    $account_name = $_POST['account_name'];
    $bank = $_POST['bank'];
    // $name = $_POST['name'];
    $account_number = $_POST['account_number'];
    $routing_number = $_POST['routing_number'];
    $swift_code = $_POST['swift_code'];
    $account_type = $_POST['account_type'];
    $address = $_POST['address'];

    // Validate user input (Add more validation if necessary)
    if (empty($account_name) || empty($bank) || empty($account_number) || empty($routing_number) || empty($swift_code) || empty($account_type) || empty($address)) {
        header('Location: manage-wallet.php?status=error&message=Enter all fields');
        exit();
    }

    // Perform database query to insert wallet data (use prepared statements for security)
    $insertQuery = "INSERT INTO wallet (account_name, bank, account_number, routing_number, swift_code, account_type, address) VALUES (?, ?, ?, ?, ?, ?, ?)";
    $insertStmt = $conn->prepare($insertQuery);

    if ($insertStmt) {
        $insertStmt->bind_param("sssssss", $account_name, $bank, $account_number, $routing_number, $swift_code, $account_type, $address);
        $insertStmt->execute();

        // Check for errors in the insertion query
        if ($insertStmt->error) {
            header('Location: manage-wallet.php?status=error&message=Error in database query: ' . $insertStmt->error);
            exit();
        }

        $insertStmt->close();
        header('Location: manage-wallet.php?status=success&message=Wallet added successfully');
        exit();
    } else {
        header('Location: manage-wallet.php?status=error&message=Error in database query: ' . $conn->error);
        exit();
    }
} else {
    header('Location: manage-wallet.php?status=error&message=Invalid request');
    exit();
}

// Close the database connection
$conn->close();
?>
Back to Directory File Manager
<