我使用PHP 5.6和PHPstorm 10.
以下的HTML代码。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
</head>
<body>
<form action="hello.php" method="post">
<input type="text" name="blabla">
<input type="submit">
</form>
</body>
</html>
以下PHP代码。
<?php
echo $_POST["blabla"];
?>
但是,如果我将方法更改为GET
。
这将是工作。但我无法获得后期价值。
然后我安装WAMP Server。当只是使用WAMP Server访问时,它工作了。为什么我不能使用PHPStorm来获取帖子值。
答案 0 :(得分:1)
您需要通过以下方式检查“请求类型”: -
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'POST') {
// Method is POST
echo "post";
$data = isset($_POST["blabla"]) ? $_POST["blabla"] : 'notset';
echo $data; // print data
} elseif ($method == 'GET') {
// Method is GET
echo "get";
} else {
// Method unknown may be put or delete
echo "unknown";
}
希望它会对你有所帮助:)。
答案 1 :(得分:1)
删除表单<{p>}的method = "post"
以下PHP代码。
<?php
echo $_REQUEST["blabla"];
?>