0

I have this problem: Not all POST data are sent from the browser or not are available on the form's action page.

I need to know:

  • what are the causes?
  • how to control what is the cause?
  • how to fix this?

The action's page doesn't return any error (even if I set error_reporting(E_ALL); ). The server is Linux. The form's input are many, some are arrays with a maximum level of two nested keys (array[1][2]).

I tried to send less inputs and it works, but I need to use all the inputs in the page.

I printed all the POST data received by the form's action page and the last inputs there aren't in the $_POST variable.

Thanks

user2342558
  • 5,567
  • 5
  • 33
  • 54
  • see http://stackoverflow.com/questions/3263480/upload-max-size-in-php – Waygood May 02 '13 at 10:23
  • Can you say how large (in bytes) the expected input is? How large is the truncated input? And can you add your HTML form-code, the data you get and also the data you expected instead to your question. This should give it some more context. – hakre May 02 '13 at 10:43

3 Answers3

5
  • what are the causes?

Causes are most often PHP configuration. But it is also possible that the HTTP request was broken or the webserver is misconfigured.

  • how to control what is the cause?

You control the configuration with PHP configuration. Same for the webserver. For the broken requests, you need to check if the network is okay, but you can not always control that because normally you don't have control over the whole network. So you can only take care about the part you control.

  • how to fix this?

Best way is to first find out which parts are not affecting this. That means you should first of all exclude that the network is the problem (is the incomming request OK? you can verify that with a network sniffer).

Next step is that you ensure the webserver is working properly. Most webservers assist you with that, check the documentation of the product you use here for your options.

For example if you're using Apache this can be settings like LimitRequestBody or if you've got security modules installed, setting of these modules.

If you're sure that actually PHP is causing the Issue:

As far as the PHP configuration is concerned, the configuration is outlined and documented in the PHP manual. You should start with the

The following options are most often relevant. All need to be set in php.ini or .htaccess only (these won't work using ini_set()):

These are some common culprits but I can not outline all configuration settings that could play a role. Many of these core php.ini directives could apply if you've got broken data. Check especially the HTTP and the Data sections there.

A very important thing is - as you do input processing - that you need to log errors. At the time the data comes to PHP and where it got broken, those errors can only be logged to disk - not displayed. So you need to enable error logging and follow the error log. For the related configuration of PHP Error Handling see a different part in the PHP manual:

hakre
  • 193,403
  • 52
  • 435
  • 836
0

If you have acces to your php.ini, check if the post_max_size parameter is enough for your inputs.

Freeman Lambda
  • 3,567
  • 1
  • 25
  • 33
0

You can check to see if it's a true memory problem by TEMPORARILY adding this to your PHP code:

ini_set('memory_limit', '-1');

This will allow your script to use the max amount of memory available.

If you discover that the problem is memory related, you can adjust the size of the memory block required using the same code, but substituting '-1' with your memory requirements.

LovinItAll
  • 133
  • 1
  • 2
  • 8
  • I have error_reporting(E_ALL); but no errors. I tried ini_set('memory_limit', '-1'); but doesn't solve the problem. – user2342558 May 02 '13 at 10:29
  • Perhaps you can post your code? Just a note: I have a C# Winform app that sends a VERY LARGE amount data via POST to a php script. I was experiencing similar problems, but I was receiving an error message (I know you aren't). Can you run a PHP debugger server-side so that you can see what's being passed when you submit your form? – LovinItAll May 02 '13 at 10:35
  • I printed all the POST data received by the form's action page and the last inputs there aren't in the $_POST variable. – user2342558 May 02 '13 at 10:40
  • @user: regarding the error messages, I extended my answer to note on the potential requirement on error logging: http://stackoverflow.com/a/16335759/367456 – hakre May 02 '13 at 10:40