Fields missing from POST in PHP? This could be why

Published 11 Nov 2012 in Development, PHP & MySQL, WordPress by Alan James

So you have a webpage with a big form, with a large number of input fields, maybe loads of checkboxes or hidden inputs. The form POSTs to a PHP page which processes the data. Except, the PHP page is only receiving part of the form submission – some fields are simply missing from the POST.

Crazy, huh?

Well, maybe you’re not losing your mind after all.

Check your PHP version. I’ll lay odds it’s 5.3.9 or later.

The thing is, in PHP 5.3.9 a new environment variable was introduced to reduce PHP’s vulnerability to a certain kind of ‘Denial of Service’ (DoS) attack, by applying a maximum limit to the number of input fields which could be passed via a form POST. Any extra fields that would push the total number of fields above the limit are silently discarded.

The default limit is 1000, which may sound like a lot, but really isn’t, especially if your form is a datagrid-style editor, or maybe a WordPress admin form with extra metaboxes.

The solution? Add or edit a line in your php.ini file.

Open your php.ini file and look for a line that says max_input_vars = 1000. If it’s there, change the 1000 to a more reasonable value (for example, 10000). If it isn’t there, add the line max_input_vars = 10000 at the end of the file.

You can also see this variable and verify its value by doing a phpinfo() and then searching the resulting HTML page for max_input_vars.

On my local MAMP installation, my php.ini file was at /Applications/MAMP/bin/php/php5.3.14/conf/php.ini though of course your configuration may be different.

On a live server, you may not have access to php.ini – in which case, simply contact your hosting company and ask them to raise max_input_vars from 1000 to a more reasonable figure.

Helpful? Leave me a comment :)


  1. On 13 Nov 2012 at 08:07, Rabia Akram said:

    I am currently experiencing some problems with missing post from data.when a variable is long or sometime even with small,the post is still not outputed.

  2. On 15 Nov 2012 at 16:36, Tom Marin said:

    This has been bugging me for days – problem solved! THhank you so much!

  3. On 17 Nov 2012 at 10:55, Kate said:

    my friends had the same issue a week ago but he has solved it himself but he never thought of publishing the solution like you did. These day to day problems should be part of blog posts where people can find solutions.

  4. On 26 Nov 2012 at 21:05, Amin said:

    max_input_vars for one session or for all sessions ?!!

  5. On 03 Dec 2012 at 10:50, Beverly Ruiz said:

    Thanks for the tip. I’m actually having a little bit of problems. I hope your tip helps, thanks again!

  6. On 07 Dec 2012 at 19:28, Rebecca Evans said:

    The reason why some of my fields are missing is simply because a new environment variable was introduced? This is fair. I’m glad you said how to solve this problem. I really thought it was only me. Thanks again.

  7. On 13 Dec 2012 at 08:22, Dosman Celthric said:

    I thought I was the only one here! Looks like many people experience such problems. I’ll try your solution now and see if it will work. Thanks again!