【发布时间】:2021-04-11 00:11:00
【问题描述】:
我在下面写了这段代码,当我提交表单时,$_SERVER["REQUEST_METHOD"] 会打印 GET 而不是 POST,即使表单方法 = "POST"
<?php
include "init.php";
include $temp . "navbar.php";
echo $_SERVER["REQUEST_METHOD"];
if($_SERVER["REQUEST_METHOD"]=='POST'){
echo $_POST["name"];
}
?>
<input type="hidden" value="admin" class="title">
<form action="index.php" method="POST">
<input type="text" name="name">
<input type="submit" value="ok">
</form>
<?php
include $temp . "foot.php";
?>
【问题讨论】:
-
正确,因为你使用了
GET方法访问页面 -
当你提交表格时它应该变成
POST?当然是GET当你第一次访问页面时 -
尽管我怀疑 Areg 是对的,但您是如何访问该页面的?
-
如果你提交然后你提出
POST请求