00 Votes

PHP: Only 1000 POST-Variables are transmitted

Question by Guest | 23.10.2014 at 10:55

I am running an HTML website containing a great number of checkboxes, drop-down boxes and other input fields (configuration of many settings). All of those fields are part of an HTML form and should be passed to the PHP script when pressing the submit button.

Strangely, not all of the variables are arriving my script. When clicking on the submit button, only the first 1000 fields are transmitted, the rest is cut off. I was able to detect this by calling "echo count($_POST[]);" at the beginning of my PHP script.

What is going on there? Is it an error of PHP? What can I do to transfer all of my variables properly? Of course, it would also be possible to spread the variable to multiple forms, but I worked appreciate it to stay with my old design.

ReplyPositiveNegativeDateVotes
Avatar
1Best Answer1 Vote

Since PHP version 5.3.9, there is the value "max_input_vars" determining the maximum number of accepted input variables. By default, this value is set to 1000 and could be the reason of your problem.

You can change this value for example via the following entry in the configuration (php.ini):

max_input_vars = 5000

If your php.ini does not have any value for "max_input_vars", you can just add it.

When using Suhosin on your server, you should also adjust the corresponding values there:

suhosin.get.max_vars 5000
suhosin.post.max_vars 5000
suhosin.request.max_vars 5000

Also the transfered data is truncated when exceeding a defined size. Have a look at the value "post_max_size" in your PHP configuration for this (although, probably, in your case, it is about the number of fields and not about the size of posted data).

After changing the values, you can run phpinfo() to see whether the new changes are active. Please do not forget to restart your server to get the changes applied.
23.10.2014 at 14:03

ReplyPositive Negative
Avatar
00 Votes

If you do not have access to your php.ini configuration, you can also use the following entry in your .htaccess file:

php_value max_input_vars 5000
php_value suhosin.get.max_vars 5000
php_value suhosin.post.max_vars 5000
php_value suhosin.request.max_vars 5000

Alternatively, depending on your hoster, you can also create a php.ini or a user.ini (since PHP 5.3) in a sub directory.

However, you cannot work with ini_set("max_input_vars", 5000), because PHP do not allow this for this value.
23.10.2014 at 14:11

ReplyPositive Negative
Reply

Related Topics

Is AIDS transmitted at birth?
Question | 3 Answers

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.