为什么PHP不处理我的请求?
我有一个PHP项目,其中有一个index.html和一个简单的表单:为什么PHP不处理我的请求?,php,html,amazon-ec2,Php,Html,Amazon Ec2,我有一个PHP项目,其中有一个index.html和一个简单的表单: <p>Test connection</p> <form action="Servicios.php" method="post"> <input type='submit' name='Test' value='Test'> </form> 这是它返回的数组中的 更重要的编辑 起初我说一个简单的echo“你能打印这个吗”在主
<p>Test connection</p>
<form action="Servicios.php" method="post">
<input type='submit' name='Test' value='Test'>
</form>
这是它返回的数组中的
更重要的编辑
起初我说一个简单的echo“你能打印这个吗”代码>在主机中工作,现在我看到它也不工作。当我在中通过单击index.html中的“我的”按钮移动到Servicios.php时,浏览器会移动到Servicios.php(它会在url中显示),但它不会显示任何内容。只有当我删除了所有代码,并在上面添加了类似
的说明时,它才会显示一些内容
if(isset($_POST['Test'])){
echo 'Hello world';
}
这应该行得通。这是检查按钮是否使用POST方法提交。这应该足以检查表单是否已提交。您可以尝试使用此方法检查post方法是否已提交
if(strtoupper($_SERVER['REQUEST_METHOD']) === 'POST') {
// if form submitted with post method
// validate request,
// manage post request differently,
// log or don't log request,
// redirect to avoid resubmition on F5 etc
}
运行print\r($\u SERVER)
查看其中的内容。显示该请求的web服务器日志。好的,print\r($\u SERVER)为我提供了一个长数组,我要搜索的确切内容是什么?您能告诉我们吗?您可以查找REQUEST\u METHOD
是否确定var\u dump($\u SERVER[“REQUEST\u METHOD”])
没有显示任何内容?这对OP不起作用。这在localhost中起作用。您正在删除使用empty()
进行的检查OP,不需要将其设置为大写(),如果使用equal进行检查不起作用,使用相同的也不起作用。。。
["SERVER_PROTOCOL"]=> string(8) "HTTP/1.1"
["REQUEST_METHOD"]=> string(4) "POST"
["QUERY_STRING"]=> string(0) ""
["REQUEST_URI"]=> string(25) "/ProyectoPM/Servicios.php"
["SCRIPT_NAME"]=> string(25) "/ProyectoPM/Servicios.php"
["PHP_SELF"]=> string(25) "/ProyectoPM/Servicios.php"
["REQUEST_TIME_FLOAT"]=> float(1510847672.582)
["REQUEST_TIME"]=> int(1510847672) }
if(isset($_POST['Test'])){
echo 'Hello world';
}
if(strtoupper($_SERVER['REQUEST_METHOD']) === 'POST') {
// if form submitted with post method
// validate request,
// manage post request differently,
// log or don't log request,
// redirect to avoid resubmition on F5 etc
}