表单发送空POST(有时)


forms sends empty POST (sometimes)

我的webapp(php,kohana 2.x)有问题,我真的不知道如何解决它。这种情况只发生在一些用户身上,不管怎样,我都无法通过更改浏览器来复制它。通常情况下,登录表单是有效的,但有时它会发送NULL post:

language en_US
2012-01-07 19:55:24 +01:00 --- info: Called login, but POST is empty.
2012-01-07 19:55:24 +01:00 --- info: <pre>(array) Array
(
)
</pre>
2012-01-07 19:55:24 +01:00 --- info: <pre>(array) Array
(
)
</pre>

这是表单代码:

<div id="form">
<form action="/index.php/user/login" method="post">
<input type="text" id="username" name="username"  style="width:140px">
<input type="password" id="password" name="password"  style="width:140px">
<input type="submit" id="submit" value="Enter" class="submit"  />           
</form>
</div>

有线索吗?

谢谢。

更新:用户再次遇到问题:这是包含您要求查看的信息的日志文件:

2012-01-18 05:28:06 +01:00 --- info: ----------------------------------------
2012-01-18 05:28:06 +01:00 --- info: IP address: x.x.x.x
2012-01-18 05:28:06 +01:00 --- info: Method: POST
2012-01-18 05:28:06 +01:00 --- info: Type: application/x-www-form-urlencoded
2012-01-18 05:28:06 +01:00 --- info: Length: 34
2012-01-18 05:28:06 +01:00 --- info: Raw: username=xxx&password=yyy
2012-01-18 05:28:06 +01:00 --- info: ----------------------------------------
2012-01-18 05:28:07 +01:00 --- info: ----------------------------------------
2012-01-18 05:28:07 +01:00 --- info: ----------------------------------------
2012-01-18 05:28:07 +01:00 --- info: IP address: x.x.x.x
2012-01-18 05:28:07 +01:00 --- info: Method: GET
2012-01-18 05:28:07 +01:00 --- info: Type:
2012-01-18 05:28:07 +01:00 --- info: Length:
2012-01-18 05:28:07 +01:00 --- info: Raw:
2012-01-18 05:28:07 +01:00 --- info: ----------------------------------------

Apache访问日志:

x.x.x.x - - [18/Jan/2012:05:27:47 +0100] "GET /media/images/template/table-bottom.png HTTP/1.1" 200 80034 "http://www.medieval-europe.eu/index.php/" "M
ozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.
30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:27:47 +0100] "GET /media/images/template/background.jpg HTTP/1.1" 200 220187 "http://www.medieval-europe.eu/index.php/" "Mo
zilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.3
0729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:06 +0100] "POST /index.php/user/login HTTP/1.1" 302 782 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compati
ble; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveCo
nnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:07 +0100] "GET /index.php/region/view_announcements/region/106 HTTP/1.1" 302 602 "http://www.medieval-europe.eu/index.ph
p/" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CL
R 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:07 +0100] "GET /index.php/user/login HTTP/1.1" 302 572 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatib
le; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveCon
nector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:08 +0100] "GET /index.php/ HTTP/1.1" 200 5854 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatible; MSIE
8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.
3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:09 +0100] "GET /media/css/home.css HTTP/1.1" 304 241 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatible
; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConne
ctor.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:21 +0100] "GET /index.php/page/index HTTP/1.1" 200 5854 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/
4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:22 +0100] "GET /media/css/home.css HTTP/1.1" 304 241 "http://www.medieval-europe.eu/index.php/page/index" "Mozilla/4.0 (
compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Offic
eLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:30 +0100] "POST /index.php/user/login HTTP/1.1" 302 782 "http://www.medieval-europe.eu/index.php/page/index" "Mozilla/4.
0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Of
ficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:30 +0100] "GET /index.php/region/view_announcements/region/106 HTTP/1.1" 302 602 "http://www.medieval-europe.eu/index.ph
p/page/index" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.215
2; .NET CLR 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:30 +0100] "GET /index.php/user/login HTTP/1.1" 302 572 "http://www.medieval-europe.eu/index.php/page/index" "Mozilla/4.0
 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Off
iceLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:31 +0100] "GET /index.php/ HTTP/1.1" 200 5854 "http://www.medieval-europe.eu/index.php/page/index" "Mozilla/4.0 (compati
ble; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveCo
nnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:32 +0100] "GET /media/css/home.css HTTP/1.1" 304 241 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatible
; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConne
ctor.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:42 +0100] "POST /index.php/user/login HTTP/1.1" 302 782 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compati
ble; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveCo
nnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:42 +0100] "GET /index.php/region/view_announcements/region/106 HTTP/1.1" 302 602 "http://www.medieval-europe.eu/index.ph
p/" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CL
R 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:43 +0100] "GET /index.php/user/login HTTP/1.1" 302 572 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatib
le; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveCon
nector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:43 +0100] "GET /index.php/ HTTP/1.1" 200 5854 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatible; MSIE
8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.
3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:44 +0100] "GET /media/css/home.css HTTP/1.1" 304 241 "http://www.medieval-europe.eu/index.php/" "Mozilla/4.0 (compatible
; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConne
ctor.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:58 +0100] "GET /index.php/page/index HTTP/1.1" 200 5955 "-" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/
4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:59 +0100] "GET /media/css/home.css HTTP/1.1" 200 4340 "http://www.medieval-europe.eu/index.php/page/index" "Mozilla/4.0
(compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; Offi
ceLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:59 +0100] "GET /media/images/flags-lang/gb.png HTTP/1.1" 200 921 "http://www.medieval-europe.eu/index.php/page/index" "M
ozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.
30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"
x.x.x.x - - [18/Jan/2012:05:28:59 +0100] "GET /media/images/flags-lang/it.png HTTP/1.1" 200 742 "http://www.medieval-europe.eu/index.php/page/index" "M
ozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; EasyBits GO v1.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.
30729; OfficeLiveConnector.1.3; OfficeLivePatch.0.0)"

我了解到有一些浏览器插件正在处理用户访问的其他请求链接。

一个例子是一个Chrome插件,它在地址栏中显示一些服务器标题,该插件向服务器发送额外的请求以读取标题信息,并在用户不知情的情况下产生第二个请求。我的网上银行和几个基于cookie的会话处理网站因此而崩溃。

要确定问题的来源,您应该记录尽可能多的数据,如该链接请求的完整$_SERVER和$_REQUEST数组。为了更好地了解情况,您应该将您的分析与Web服务器日志文件结合起来,以查看在"null"提交之前由同一客户端发送到服务器的所有其他请求。

我不认为Kohana应该受到谴责。我在Apache/PHP设置中也看到了同样的情况。在某些情况下,如果在对服务器的请求中未正确设置标头,$_POST将为空。

在这里查看felixsigl的代码片段,在这些情况下将原始http输入转换为$_POST

PHP缺少一些$_POST值,但存在于php://input

尝试将"/"添加到表单操作:

<form action="/index.php/user/login/" method="post">