当用户单击submit时,它同时向脚本发送一个post和get请求。Post返回302查找,Get返回200,但是print_r在表单提交后显示一个空数组。我搞不懂为什么会这样。
这是在使用PHP5.4和Apache2.4的AWS Linux实例上运行的。
以下是代码:
<?php
print_r($_REQUEST);
?>
<!doctype html>
<html>
<meta charset="UTF-8" />
<title>Login</title>
<head>
</head>
<body>
<p>Please login:</p>
<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
<table>
<tr>
<td>
username
</td>
<td>
<input type="text" name="username" id="username" style="width:400px;"> (case sensitive)
</td>
</tr>
<tr>
<td>
password
</td>
<td>
<input type="password" name="password" id="password" style="width:400px;">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="submit">
</td>
</tr>
</table>
</form>
</body>
</html>当我单击submit时,我在FF开发工具中看到了以下内容:

发布于 2016-11-03 20:07:32
你不会发邮件和只发邮件。然后,您的服务器使用重定向(302)进行响应,这使浏览器通过GET加载给定的URL。此时,数据丢失(由于重定向),数组为空。问题是为什么您的服务器指示重定向。最可能的原因是您的htaccess文件。你能把它寄过来吗。
https://stackoverflow.com/questions/40410232
复制相似问题