Submitting large amount of data in a form with PHP max_input_vars

Recently I was working on a project which had an Excel-like spreadsheet fully implemented in jQuery using the HandsomeTable plugin (
The number of rows to be saved was unpredictable and all the data was submitted on a POST request to the server. When tried to save it got saved only partially data, rest of rows got truncated. Checking if there were any PHP errors, I found the following in the error logs:

PHP Warning: Unknown: Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini. in Unknown on line 0, referer: http://example/process

There is a PHP setting “max_input_vars” which limits the number of variables that PHP will process. If this value is 1000 (default is 1000) PHP will process first 1000 variables and drop the remaining throwing no errors to the browser.

To solve this issue we need to increase the “max_input_vars” to a bigger number.
There are 2 ways. Either by changing the variable in .htaccess file (or your VirtualHost config file) or php.ini file.

1. Change max_input_vars using .htaccess file

Add the following line in you .htaccess file.

php_value max_input_vars 2000

2. Change max_input_vars using php.ini file

Edit your php.ini file and search for “max_input_vars“. this might look something similar to following:

; max_input_vars = 1000

The above line is commented, that means it will take PHP’s default value which is 5000. To change it to 5000 change that line to be:

max_input_vars = 5000

After this change you will have to restart Apache server.


2 thoughts on “Submitting large amount of data in a form with PHP max_input_vars

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s