6

It seems like there is a problem with older PHP versions and more than 1000 input fields in one form (see this question).

If I run a webserver with an older PHP version, is there a limit to the maximum number of form elements in (one nesting level) like it is controlled by the php.ini directive max_input_vars since PHP 5.3.9?

Or is there no limit in older versions?

What happens if I set this variable anyway in older versions in php.ini or .htaccess?

I noticed, that on my server I run PHP 5.3.3-7+squeeze17 which also already has the directive max_input_vars.

How exactly did older versions behave?

Community
  • 1
  • 1
rubo77
  • 19,527
  • 31
  • 134
  • 226

3 Answers3

3

It seems there is confusion:

http://www.flowstopper.org/2012/12/my-php-wtf-of-day-maxinputvars.html

Although the docs say: "Available since PHP 5.3.9."

http://php.net/manual/en/info.configuration.php

If I had to guess I would say there was always a limit, and it just got pulled out into the config/documentation in 5.3.9

ddoor
  • 5,819
  • 9
  • 34
  • 41
1

There seems to be a bug in older versions:

https://bugs.php.net/bug.php?id=65778

although you can alter the directive in php.ini and the change is shown correctly in phpinfo(), it has no effect.

Behaviour: all variables exceeding 1000 are ignored

tested in PHP 5.3.3-7+squeeze17 without suhosin module

A possible workaround: compact all form-data with javascript

Community
  • 1
  • 1
rubo77
  • 19,527
  • 31
  • 134
  • 226
-1

I think your problem is not the number of yourform fields, I think the total data you are sending is to much.

There is an php.ini directive that limits how much data you totally can send on a post request (check: post_max_size).

But you can not change post_max_size while runtime (because this value is checked before the first line of you php files during input phase of php).

Your have several ways to change this value:

  1. In Webserver Config
  2. in a htaccess file

with the following code:

php_value post_max_size 512M # set maximum post data to 512 MB
  1. in your global php.ini
  2. in your users.ini (if it's configured)

with the following code:

post_max_size = 512M
Radon8472
  • 4,285
  • 1
  • 33
  • 41
  • I am aware of the post_max_size directive and your hints are all correct, but it is not connected to my question. I have a form with over 1000 radiobuttons, that could be hardly as much as a few MB. I really want to know about the variable **max_input_vars** – rubo77 Sep 27 '13 at 15:37
  • 1
    Sorry, but your question gives no information what kind of form elements you are talking about. I yust answered: 'there is **no limit** for the number of fields in PHP 5.3.3 but it has another limitation that may give a limit for input_vars' – Radon8472 Oct 01 '13 at 15:52