Jump to content

[SOLVED] Post array size limit, but not MB


SammyP

Recommended Posts

I have a form which has a variable size, depending on the number of rows in a table. For each row there are about ten fields, and I simply show them all for each row.

 

I've recently started having a trouble in that if I create a form with more than 400 elements, then the $_POST variable is truncated at 400. Is this normal? Do I have to limit the size of the $_POST array? Not by MB, which must be trivial for me, but for the number of array elements?

 

Link to comment
Share on other sites

There is no limit on the number of elements. Also, if you were exceeding the post max size, the whole post array is empty. It is more likely that your form is invalid HTML or your form processing code has a logic error that is preventing it from operating on all the data. Have you examined the resulting html and/or validated the page at http://validator.w3.org/

Link to comment
Share on other sites

I agree with PFMaBiSmAd.  Out of curiosity I set up a test page with a bazillion inputs and it submits just fine no matter how many there are (albeit, very slowly).

 

Thanks to you guys for the comments, but I've checked and I really seem to have this limitation. I've added different numbers of input elements to the start of the form and everything happens in a way that suggests there is a 400 element limit to my post array.

 

Firstly, in my created HTML, there is no problem, the form looks as I'd expect. All of the elements are there.

 

In my processing, I now echo out the count of the Post array and it is always 400. If I add two dummy elements near the start, when I loop through the Post array the final two from the time before are not there.

 

Does anyone have any idea what might cause this? I don't want to go to the trouble of limiting the number of elements on the screen. (These are personal admin screens and I am not worried about how it looks.)

 

Sam.

 

(Like the quote flyhoney!)

 

 

 

 

 

 

Link to comment
Share on other sites

I just tried this code

 

<?php
if (!isset($_POST['test0'])) {
$output = '<form name=test method=post>';
$string = <<<STRING
I have a form which has a variable size, depending on the number of rows in a table. For each row there are about ten fields, and I simply show them all for each row.
I've recently started having a trouble in that if I create a form with more than 400 elements, then the $_POST variable is truncated at 400. Is this normal? Do I have to limit the size of the $_POST array? Not by MB, which must be trivial for me, but for the number of array elements?
STRING;

for ($i=0;$i<500;$i++) 
	$output .= '<input type="hidden" name="test' . $i . '" value="' . $i . $string . '" />';

$output .= '<input type="submit" value="submit" /></form>';
echo $output;
}else {
echo '<pre>' . print_r($_POST, 1) . '</pre>';
}
?>

 

On my server and received 499 elements of the array. Which is correct.

 

I am not sure why your server is chopping it up, but yea. On a side note I believe there is a post_max_size variable in the php.ini file. Maybe try changing that to be larger than it is?

 

My setup is WAMP on Windows using FireFox 3 and yea it worked just fine. I also tested it with 1,000 items, still worked fine.

Link to comment
Share on other sites

I have found some information on this if anyone is interested. I ran phpinfo() and searched for 400.

 

It came up as a variable called suhosin.post.max_vars in some security module (Suhosin) my host company has installed. Set to 400 obviously.

 

So I've asked how to circumvent it and will do so if I can, and in case it helps I'll post out how I did it here. If it is possible at all.

 

Sam.

 

 

 

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...
  • 1 year later...

Essential little thing you forgot to mention and I just experienced myself.

 

If you raise suhosin.post.max_vars you also need to make sure, that suhosin.request.max_vars is also raised to this new maximum, because otherwise it would overwrite the suhosin.post.max_vars.

I also raised max_input_vars from php to make sure really NOTHING keeps inputs from getting posted.

 

Code in vhost.conf (Plesk based ^^).:

php_admin_value suhosin.post.max_vars 5000
php_admin_value suhosin.request.max_vars 5000
php_admin_value max_input_vars 5000

Should work in .htaccess, too. But I have not tested it.

 

func0der

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.