Web Hosting Talk







View Full Version : $_POST array size


Codebird
09-02-2008, 10:01 AM
hello

I have a form that has 246 check boxes and at last a hidden input which is the count of the check boxes cause they are not always 246. the problem is that when all the 246 check boxes are checked the form is not being well processed because I think the $_POST array doesn't hold over a certain number of values. what should I edit in the php.ini so that it holds big number of variables.

Thanks

Sheps
09-02-2008, 11:04 AM
I can get a check for 260 checkboxes to appear. So it is not a problem with limits of php variables. I think there is a coding issue.

http://www.dansheps.com/postarray.php

For a example

Codebird
09-02-2008, 12:17 PM
thanks for the reply but it is for sure not a coding problem cause when testing on my pc everything works fine and when I don't check more than 150 check boxes on the server everything works fine and before there wasn't there 246 check boxes and everything was working fine, and I didn't change anything in the code. I am sure it is something with the server's settings but I can't find what it is and support is asleep I guess

aradapilot
09-02-2008, 12:19 PM
with a variable number of checkboxes, how are you naming each one? depending on what criteria make each show up, you may have this problem: (example of 3 checkboxes)
checkbox1, checkbox2, and checkbox3 are the possible total boxes.
checkbox1 and checkbox3 are set to display on the page. hidden input count says 2 checkboxes.
when form is submitted and processed, you may be looping through twice looking for checkbox1 and checkbox2...the script wouldn't know that 2 was skipped and 3 was displayed, because the count just said 2. therefore the input is received wrong.
a simple solution is to just loop through the $_POST keys in a foreach, seeing if the key is a checkbox name, and processing it appropriately.
Seen this happen before, so it might be what you're facing. To my knowledge there is no size limit on superglobals like $_POST.

Codebird
09-02-2008, 12:25 PM
the checkboxes are named fine email1 email2 email3...... then in the other script it is checking if the check box is checked then something happens if not nothing happens... I repeat I am 100% the script is fine the problem is with the size of the post array

Codebird
09-02-2008, 12:42 PM
I think it is the suhosin that is putting size constraints on the post array at last that is what I understood from the support but they never really say what variable should be changed and I can't try many things cause at each time I am restarting the apache while the site is online and working fine

Sheps
09-02-2008, 12:44 PM
But it is obviously not fine, because if you take a look at my script, which dynamically generates 260 checkboxes all 260 checkboxes show up.

My guess is you have your checkboxes named in such a manner to prevent you from having more then 150 checked.

Codebird
09-02-2008, 12:49 PM
I just rechecked the code and everything is fine I have the check boxes named email1 email2...... email262 (now that the number of emails has grown) and that is the counter at the end of the form <input type="hidden" id="counter" name="counter" value="262" />
as a plus and a prove when I check all the emails and I just try to echo $_POST["counter"] it echoes nothing. and 1 more time if there was a code error not settings why would the code work fine on my pc (localhost) and it doesn't work on the server??? Sheps is there suhosin on your server? can u send me your php.ini or something if there is please. Thanks

aradapilot
09-02-2008, 01:01 PM
what is post_max_size set to in your php.ini? the default is something absurdly large like 8M. it'd have to be very very small to affect only 260 checkboxes.

Codebird
09-02-2008, 01:07 PM
it is not the php as php that is blocking them it is the suhosin

look at these:


suhosin.post.max_array_depth 1000 1000
suhosin.post.max_array_index_length 1000 1000
suhosin.post.max_name_length 64 64
suhosin.post.max_vars 1000 1000
suhosin.request.max_vars 200 200


these values I copied from the phpinfo() something in these I guess it is me who have put the 1000 yet nothing happened and as I said I can't keep on trying values cause at each time I am having to restart the apache. I need this for another site that is working on the server too

Codebird
09-02-2008, 01:12 PM
I have done it, I have changed this

suhosin.request.max_vars 200 200

to 1000 it works fine thanks guys

suhosin.post.max_vars 1000 1000

suhosin.request.max_vars 1000 1000