I am having an issue transferring values between pages in PHP using POST. I am using a hidden field at the bottom of a page to state how many items (rows of students) I have on the page. I also have a filter option which reduces the number of items visible on the page. When I submit data from the filtered page, all values (including the hidden ones) get through no worries. When I submit data with the page unfiltered, the hidden values do not get through (and therefore my data collection does not happen).
The clincher is, this does not happen in my Apache based test environment, it only happens when I move this to an IIS based production environment.
Here is a screen shot of the initial page (actual data has been removed for privacy reasons), which shows the inputs. There are 12 rows of 30 inputs each (360 total): <img alt="Data input page" class="b-lazy" data-src="https://i.stack.imgur.com/QYjXW.png" data-original="https://i.stack.imgur.com/QYjXW.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />
Here is the HTML code with the hidden fields which I need:
<input type="hidden" value="12" name="numStudents"> <input type="hidden" value="10" name="numTasks"> <input type="hidden" value="3" name="numCriteria"> <input class="btn btn-primary btn-large" type="submit" value="Save" name="submit">
Here is the PHP code which receives the values:
//Get the general information from the form $numStudents = $common->clean($_POST["numStudents"], $CON); $numTasks = $common->clean($_POST["numTasks"], $CON); $numCriteria = $common->clean($_POST["numCriteria"], $CON); //Loop to get grades for all students $output = ""; $flagChange = FALSE; $count = 0; for($i = 0; $i < $numStudents; $i++)
When I echo out the value of either $numStudents or $_POST["numStudents"] directly, nothing appears.
The really confusing thing is - when I have a list of 1 or 2 students, the unfiltered data comes through without an issue (the echo displays the correct value). As mentioned before, if I filter the data so that only 6 columns of inputs are shown for each student, the data comes through without an issue.
Does IIS have a maximum number of values allowed in the POST variable? If so, can this be changed? I have checked my PHP.ini file and the max size of post is set to 8M (which this data should not even approach).
Is there another setting somewhere I need to change?Answer1:
The maximum size of POST data that can be sent is a per server setting. For PHP/APACHE it can be set from the .htaccess as:
#set max post size php_value post_max_size 20M
Under IIS you want to change the
See: <a href="http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits" rel="nofollow">http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits</a>Answer2:
So, I was able to re-frame my search query to find a solution to this. It turns out that there is a setting in PHP for the maximum number of elements allowed within the POST array. My limit was set to the default of 1000, I have now upped this to 3000.
The setting in the PHP.ini file is: max_input_vars
I found this page helped solve this issue:
<a href="https://stackoverflow.com/questions/9807100/post-max-array-size" rel="nofollow">$_POST max array size</a>