0

I'm learning php on the job and I wasn't doing too badly until this problem has been blocking me for several days.

From a Data.php file, I retrieve data from an API in JSON, which I display in the browser on the one hand and place in a form on the other hand. It is an array of 5 columns and as many rows as data to recover.

In my form, I create a hidden input named table[i] per new line and a sub-input table[i][j] per column of line i. I then send it by POST method to a Data_post.php file, which sends it to a personal database.

All this worked very well until I tested with "larger" data ranges. In this case, my Data_post.php page returns this message : Error message

Here is the part of the code concerned in Data_post.php : concerned code

From what I understand the file does not recognize one of the variables transmitted by the form. Looking around, I realize that this only happens from the 358th iteration of the for loop. As if the form was sent correctly for the first 357 lines but not for the following ones.

By inspecting the Data.php page from which the form comes, I see that all variables are well defined even beyond line 358: form inspection

This would therefore come from the transmission between Data.php and Data_post.php.

I looked at the max_size or execution_time in php.ini but it would surprise me that the problem comes from there since my form remains very light (here 358 lines * about one hundred characters per line).

So I hope you will have some ideas to help me because I really have drawn on all my skills, so far uselessly.

Thank you very much in advance!

  • 1
    Hi Gustave, welcome to stack overflow. If you supply code samples of what you're doing it would be helpful. Images are more difficult for other to decipher and look through. The easier you can make it on other the more likely they are to help you. I would recommend looking at a Minimum reproducible answer. https://stackoverflow.com/help/minimal-reproducible-example – domdambrogia Nov 20 '19 at 03:09
  • I would also consider looking at your max post size in your php ini settings: https://stackoverflow.com/questions/6135427/increasing-the-maximum-post-size – domdambrogia Nov 20 '19 at 03:11
  • I see a lot of hidden fields with no values, what purpose do they serve? – Scuzzy Nov 20 '19 at 03:11
  • Try checking PHP.ini `max_input_vars` as well.. – peekolo Nov 20 '19 at 07:11
  • Thank you so much @peekolo that was the solution ! Thank you everyone for your answers. – Gustave Behr Nov 21 '19 at 05:40
  • @Scuzzy you're right it's awkward, I wanted to structure my form but it's better with div and inputs inside the div. Thanks. – Gustave Behr Nov 21 '19 at 05:43
  • Glad I could help. Left the answer as an actual answer for others to see in case they are searching for similar solutions. You can mark it as accepted answer if it helps! – peekolo Nov 21 '19 at 06:44

1 Answers1

2

Leaving the answer here for posterity.

php.ini max_input_vars limits the number of post variables.

How many input variables may be accepted (limit is applied to $_GET, $_POST and $_COOKIE superglobal separately). Use of this directive mitigates the possibility of denial of service attacks which use hash collisions. If there are more input variables than specified by this directive, an E_WARNING is issued, and further input variables are truncated from the request.

https://www.php.net/manual/en/info.configuration.php#ini.max-input-vars

peekolo
  • 342
  • 3
  • 8