4

The Background
I am using CodeIgniter 2.1.4 and PHP 5.3 running on Nginx. I have an HTML form representing what is essentially rows of homogeneous data. Each "row" has several <input /> fields, each with the same name. Here's a simplified example:

<input type="text" name="firstname[]" />
<input type="text" name="lastname[]" />

So, I've got many firstname[] inputs, lastname[] inputs, etc. After submitting the form (the action is POST), I retrieve the data in a controller method like so (note that I'm using CodeIgniter):

$firstnames = $this->input->post('firstnames');
$lastnames = $this->input->post('lastnames');

These variables are arrays containing the values from the corresponding rows in the form, and from here I do some processing on this data.

The Problem
When the number of rows in the form is large (several hundred), the size of the resulting PHP arrays do not match the number of inputs in the form -- for example, the form might have 200 firstname inputs, but the $firstname array only has 167. What's more, the $lastname variable has a different size as well -- 166.

When the form has a smaller number of elements, everything works fine.

My theory is that I am exceeding some sort of maximum size setting or buffer somewhere in the stack, causing the form data to be truncated. Is there a PHP or CodeIgniter or nginx setting for "maximum form size" that I am not aware of?

For what it's worth, I have seen the same behavior when using both application/x-www-form-urlencoded or multipart/form-data as the content type for the form.

What am I missing?

Donut
  • 110,061
  • 20
  • 134
  • 146
  • Most likely you have the suhosin php security patch installed. It limits the number of input parameters allowed. – arkascha Nov 01 '13 at 16:06

1 Answers1

7

Assuming no suhosin... Then see: max_input_vars and max_input_nesting_level.

These are newer and often overlooked when people think of POST limits in PHP.

But if its truncated like you say then maybe it is just your post_max_size.

Also, this just has to be a dupe question...

PHP max_input_vars Increasing the maximum post size etc..

Community
  • 1
  • 1
ficuscr
  • 6,975
  • 2
  • 32
  • 52
  • 1
    The problem was `max_input_vars`. It was set at 1000, and each "row" in my form had 6 inputs. 1000 / 6 = 166.6; so whenever I had more than 167 "rows", I encountered this problem (and some of my arrays contained 166 items, while others contained 167). Thanks for your help! – Donut Nov 01 '13 at 17:13
  • Mine was commented. I just un-comment it and set to 10000. So far so good. If this is a mistake, somebody please comment. – Apit John Ismail Nov 07 '17 at 12:21