The other day a colleague was having a very puzzling problem with PHP POST Variables, he was posting an array of values from a large form but some of the values were missing from the $_POST variable. After looking through his code a couple of times we came to the conclusion that the code was correct, so I started looking into Apache settings to see if there were any limits on how large the $_POST can be.
It turns out there are 2 variables in the PHP php.ini file for controlling the size of the $_POST variable, the first variable is post_max_size which takes either a KB or MB value which defines the maximum file size the $_POST variable can become before it is clipped. And max_input_vars which defines how many actual variables can be stored in the $_POST array before they are clipped.
After changing these values the $_POST started listing all the data we was previously missing, which was a big relief for us!
How to find php.ini
php.ini can be in several locations depending on your system, if none of the locations below refer to your installation then please consult your systems help files or contact your hosting provider.
On all most all distro's of linux you can find the location at:
On Windows the php.ini could be in several different locations:
Another way to find your php.ini is to use phpinfo() function in a PHP script, create a php file with the following data:
Open the file in a browser and look for "php.ini" and the path should become apparent.
Once you have access to your php.ini, open it in your favourite editor (on linux you can use the command nano php.ini).
You need to look for the following variables and change the values accordingly:
post_max_size = 15M
max_input_vars = 100
Obviously increase these variables to suit your requirements, you may not need 100 variables, be sensible as having a very large post size could make your server more vulnerable to attack.