php – POST不发送所有数据

我有一个大约135个复选框的屏幕

<input type="checkbox" name="orders_id[] value="1"/>
<input type="checkbox" name="orders_id[] value="2"/>
.........
<input type="checkbox" name="orders_id[] value="135"/>

我检查所有复选框并提交,但在$_POST中我只看到107个复选框.

丢失的数据怎么了?

我将POST_MAX_SIZE更改为20M,但这并没有解决问题.

我从Chrome开发者工具检查了浏览器的HEADER.我可以在那里看到所有135个已检查的数据,但在PHP中,当我检查$_POST [‘orders_id’]时,我只得到107个.

最佳答案 有了这么多复选框,如果表单上有其他输入,则可能超出了PHP的max_input_vars设置.
The PHP manual将此设置定义为:

How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). Use of this directive mitigates the possibility of denial of service attacks which use hash collisions. If there are more input variables than specified by this directive, an E_WARNING is issued, and further input variables are truncated from the request.

您可以通过增加php.ini中的设置或减少表单中的输入数量以适应限制来解决此问题.

点赞