<?php
// Include database connection
include_once('_db.php');



if (isset($_POST['wallet_type'])) {
    // Sanitize the input to prevent SQL injection
    $wallet_type = $_POST['wallet_type'];

    // Prepare the SQL statement to fetch the wallet address for the selected wallet type
    $stmt = $conn->prepare("SELECT wallet_address FROM wallet WHERE wallet_type = ?");
    $stmt->bind_param("s", $wallet_type); // Bind the wallet_type parameter to the query
    $stmt->execute();
    $stmt->store_result();
    $stmt->bind_result($wallet_address);

    // If a wallet address is found, output it, otherwise output an error message
    if ($stmt->fetch()) {
        echo htmlspecialchars($wallet_address); // Return the wallet address
    } else {
        echo 'Wallet address not found'; // Return an error message if no address is found
    }

    // Close the statement
    $stmt->close();
}
?>
