【问题标题】:How to check data is coming in php (using GET method)如何检查 php 中的数据(使用 GET 方法)
【发布时间】:2017-03-26 12:27:30
【问题描述】:

我正在使用 Module SIM 808 和 Web 服务器处理一个小项目。

我使用 GET 方法将数据传输到我的网站,数据是通过 URL 发送的。

Example: www.mywebsiteaddress/?data1=sensor1_value&data2=sensor2_value.

我的网站是用 PHP 编写的。我使用 ?php echo $_GET['data1']; ?> 读取数据。 现在我想问一下,怎么查数据来了。我希望每次有新数据时都会自动“回显”。

是否有类似“微控制器中的中断服务轮播”之类的东西?

这就是我的全部代码:

<?php
 @$data1_value=$_REQUEST['data1'];
 @$data2_value=$_REQUEST['data2'];
?>


<!DOCTYPE html>
<html>
    <head>
        <title>Receive Data Using GET Method</title>
        <meta charset="utf-8">
    </head>
    <body style="font-family: Arial; font-size: 40px">
        <form action="index.php" method="GET">
            <table>
                <tr>
                    <td colspan="2" >Data Receive From Module SIM 808</td>
                </tr>
                <tr>
                    <td>Data1</td>
                    <td><input style="font-size: 40px" type="text" name="data1" value="<?php echo @$data1_value ?>" /> </td>
                </tr>
                <tr>
                    <td>Data2</td>
                    <td><input style=" font-size: 40px" type="text" name="data2" value="<?php echo @$data2_value ?>" /></td>
                </tr>
            </table>
        </form>
    </body>
</html>

从我的模块 sim 发送数据后,我的数据没有出现在文本框中。 我的数据在哪里?为什么???????

【问题讨论】:

  • 您需要向我们展示您的代码。
  • 感谢您的评论。这是我的代码

标签: php post methods get


【解决方案1】:

您可以使用 $_GET 变量获取通过 url 传递的变量。

var_dump($_GET);

如果您想确保捕获通过您的 PHP 应用程序的每个 html 获取变量,您需要让每个链接都指向一个 index.php 文件。

这样您就可以读取 $_GET 的内容,并将用户重定向到页面。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-01-05
    • 2023-03-24
    • 1970-01-01
    • 2021-12-21
    • 2015-12-08
    • 2018-12-14
    • 2015-06-13
    • 1970-01-01
    相关资源
    最近更新 更多