Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

PHP drops form fields and warns that input variables exceeded 1000

ErrorInput variables exceeded 1000. To increase the limit change max_input_vars in php.ini.

Short answer

PHP accepts only max_input_vars variables per request (default 1000) and throws away the rest, with a warning. Big forms, menu editors and bulk-edit screens hit it. Raise max_input_vars where your PHP runs, in php.ini, .user.ini or the Apache config, then reload. If the warning stays, the setting went to a file your SAPI does not read.

  • Applies to PHP 8.3, PHP 8.4, Apache 2.4, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Count what the request really sends, then see which php.ini the command line loads (the web server may use another one). Compare the count with the limit in a phpinfo() page served by the same web server.

    php --ini
    php -i | grep max_input_vars
  2. 2Match what you see, then jump to its fix

    1. 1The warning is in the log and the last fields of $_POST (or the last items of a long array) are gone.One request carries more variables than the limitFix
    2. 2You edited a setting but phpinfo() through the web server still shows 1000.The value was set in a file the running PHP does not readFix
    3. 3A php_admin_value line, or a higher-level value in the Apache config, keeps the old number.The setting was locked or set at a level that winsFix

What does the error look like?

  • Input variables exceeded 1000. To increase the limit change max_input_vars in php.ini.
  • Fields at the end of a big form are missing from $_POST

Cause 1 of 3

One request carries more variables than the limit

1Check

The manual says the limit is applied to $_GET, $_POST and $_COOKIE separately, and that extra variables are truncated from the request. Count the keys the form posts; every input in a nested array counts as one variable.

// temporary line at the top of the receiving script
error_log('POST variables: ' . count($_POST, COUNT_RECURSIVE));

2Fix

Raise max_input_vars in php.ini to a value above the largest form you need. max_input_vars is an INI_PERDIR setting, so it cannot be changed with ini_set() inside the script.

; php.ini
max_input_vars = 5000

3Verify

Reload PHP (PHP-FPM or Apache), then open phpinfo() through the web server and read the max_input_vars row.

sudo systemctl reload php8.3-fpm

Confirmed by php.net

Did this fix it?

Cause 2 of 3

The value was set in a file the running PHP does not read

1Check

A .user.ini file is processed only by the CGI/FastCGI SAPI, and PHP re-reads it every user_ini.cache_ttl seconds (default 300). php_value lines in .htaccess work only when PHP runs as an Apache module.

php --ini
php -i | grep -E "user_ini|SAPI"

2Fix

Under PHP-FPM or CGI, put the line in a .user.ini in the site's directory and wait for the cache time. Under Apache with mod_php, use php_value in the Apache config or .htaccess (AllowOverride Options or All is needed for .htaccess).

; .user.ini  (PHP-FPM / FastCGI)
max_input_vars = 5000

# .htaccess  (Apache module only)
php_value max_input_vars 5000

3Verify

Wait out user_ini.cache_ttl, then reload the phpinfo() page and read the value again.

php -i | grep user_ini.cache_ttl

Confirmed by php.net

Did this fix it?

Cause 3 of 3

The setting was locked or set at a level that wins

1Check

A value set with php_admin_value cannot be overridden by .htaccess or ini_set(). Search the Apache config for it.

grep -R -n 'max_input_vars' /etc/apache2/ /etc/php/ 2>/dev/null

2Fix

Change the number in the place that sets it, not in a lower-level file.

# in the Apache vhost, if this is where it is set
php_admin_value max_input_vars 5000

3Verify

Reload Apache and check phpinfo() again.

sudo apachectl configtest && sudo systemctl reload apache2

Confirmed by php.net

Did this fix it?

How do I stop it coming back?

  • Treat a very large form as a design problem: split it into steps or send it as one JSON field, so it never needs thousands of variables.
  • Keep max_input_vars in one config file and note it next to the app's deploy steps.
  • Watch the PHP error log after adding fields to admin screens, because the truncation is silent except for the warning.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.