RESOLVED: The issue was sort of related to max_input_vars. The server I use has a security framework called "Suhosin". There were two values that function very similarly to max_input_vars that were set to 1,000. The values were "suhosin.post.max_vars" and "suhosin.request.max_vars". I has those set to 5,000 and everything works great now!
I've currently got a page that uses PHP to display a bunch of images with print ordering options beneath them, and 'while' loops until every one is displayed. It works fine, every image is displayed. The user is meant to pick what they want to print, then click "Submit". This sends the form via the page submit.php. Submit.php generates a list of what they picked by storing the data in an array. That array is then imploded and emailed to an address as text. Four array entries are submitted for every image. The data is sent using $_POST
Now, this functions perfectly if less than 250 images are selected on the first page. If 250 or more are selected, the submit.php page turns into a Forbidden error page and no email is sent.
I assumed it was because the server is treating it as an infinite loop or maybe something to do with it handling so many array entries. I really need this fixed. Does anyone know any solutions?
EDIT - Here is the loop on submit.php. I know it's probably not the best code, I'm still learning.
EDIT 2 - I tried changing max_input_vars to 5000 and it didn't work. I added it to my PHP.ini file, the line wasn't there previously. I can't reboot server as it's shared hosting. Any other ideas?
EDIT 3 - Okay, some great progress has been made. I no longer get a Forbidden page, however the email does not send when the loop is higher than 250. It still sends successfully at < 250.
$imgcount = $_SESSION['imgcount'];
$usercode = $_SESSION['usercode'];
// echo $imgcount . "<br><br>";
$extramessage = $_POST["message"];
$currentcount = 1;
$completeorder = array();
while ($currentcount <= $imgcount) {
$x = $_POST["print_amount_" . $currentcount . ""];
// echo "<b><u>Image " . $currentcount . "</u></b><br>";
// echo $x[0] . ", " . $x[1] . ", " . $x[2] . ", " . $x[3] . ", " . "<br><br>";
$y = (string) "Image " . $currentcount . " - " . $x[0] . ", " . $x[1] . ", " . $x[2] . ", " . $x[3] . "
";
// echo $y;
$completeorder[] = $y;
// echo $completeorder . "<br><br>";
$currentcount = $currentcount + 1;
};
$completeorder = implode( "
", $completeorder );
RESOLVED: The issue was sort of related to max_input_vars. The server I use has a security framework called "Suhosin". There were two values that function very similarly to max_input_vars that were set to 1,000. The values were "suhosin.post.max_vars" and "suhosin.request.max_vars". I have now got those set to 5,000 and everything works great now!
max_input_vars, suhosin.post.max_vars and suhosin.request.max_vars all default to 1000. To check what they are set as, execute the following:
phpinfo();
Then CTRL + F and look-up those settings to see what they're set at. You might not have any "suhosin" settings in yours. If simply changing max_input_vars doesn't do the trick, CTRL + F for "1000" and see if anything that has a value of 1000 is related to "post" or "vars" or anything that would limit your maximum variables.
You are storen a lot of variables, maybe you reach the memory_limit
of your php.ini settings.
try this with some debug outputs like this:
echo "Memory: ".memory_get_usage(true) . " - PEAK: ".memory_get_peak_usage(true) . " MAX: ".ini_get("memory_limit");
But realy strange is that you get an forbidden page ... Even if reach some limits of php or of the ini_settings you normaly get an Error 500 Internal Server Error
of an visible output to your browser (only if display_errors
enabled).
So it also could be, that your webserver has some kind of restriction what is answered with an forbidden page.