【问题标题】:Getting response from sending form in textbox从文本框中发送表单获取响应
【发布时间】:2017-12-31 12:59:50
【问题描述】:

我正在尝试制作一个网站,该网站会自动使用此脚本来获取钱包中的比特币数量:

<?php
$address = $_GET["address"];
$satbalance = file_get_contents('https://blockchain.info/q/addressbalance/'.$address.'');
$btcbal = ($satbalance) / 100000000;
echo $btcbal;
?>

我正在尝试在 textarea 框中创建包含我的客户用户名和密码的页面,当我从我的用户输入比特币钱包地址以检查多个输入框中的余额并在前面的框中显示值时地址框。

Image of the page that needs this job done

如何从表单中获取响应并显示在另一个框或变量中。

谢谢。

【问题讨论】:

    标签: javascript php html css forms


    【解决方案1】:

    将字段包装在表单标签中并提交到同一页面。

    使用您的代码示例,此示例显示了一个简单的表单并使用 PHP 处理 POST。这尚未经过测试,但它是如何使用 $_POST 超级全局处理帖子的示例。

    <?php
    $btcbal = null;
    
    // Check if there is POST data
    if (!empty($_POST)) {
        $address = $_POST['address'];
        $satbalance = file_get_contents('https://blockchain.info/q/addressbalance/'.$address.'');
        $btcbal = ($satbalance) / 100000000;
    }
    
    ?>
    <form method="post">
        <input type="text" name="username">
        <input type="password" name="password">
        <input type="text" name="btc_address">
        <button type="submit">Submit</button>
    </form>
    
    <p>Balance: <?php echo $btcbal ? $btcbal : 'N/A'; ?></p>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 2018-12-11
      • 2014-06-15
      • 1970-01-01
      • 1970-01-01
      • 2015-03-31
      • 1970-01-01
      相关资源
      最近更新 更多