1

On our website, sometimes $_POST is relayed empty to the action pages.

This happens for roughly about %1-2 of the forms submitted on a daily basis. This is about 50-100 corrupt form submissions per day currently.

We are certain the data is there on the initial page. We tried sending the same data with $_POST and $_GET at the same time with the exact same values. $_GET reaches the action page all the time, but $_POST can arrive empty.

Often times, this error happens to Webkit besed browsers. Also mobile phone browser seem to be more prone to this. IE browsers experience this less than the Webkit browsers. And very rarely it happens to Firefox as well.

Current configuration is like this:
PHP Version 5.2.15
Centos 5
Apache 2.2.3

One thing we are discussing is to upgrade our PHP to 5.3.x. Does that sound like a reasonable try?

Any suggestions on how we can try to debug this?

UPDATE: Submission form is as follows:

<form action="submit.php?receiver_user_id=<?php echo $_SESSION['receiver_user_id'];?>&sender_user_id=<?php echo $_SESSION['user_id']; ?>" method="post">
  <textarea name="message_text" ></textarea>
  <input type="hidden" name="receiver_user_id" value="<?php echo $_SESSION['receiver_user_id'];?>
  <input type="hidden" name="sender_user_id" value="<?php echo $_SESSION['user_id']; ?>
  <input type="image" name="submit" src="submit.png" value="submit"/>
</form>
Haluk
  • 2,091
  • 2
  • 27
  • 35
  • 1
    "On our website we have a bug which we could not fix for more than a year now." - maybe time to hire an expert? – Mitch Wheat Jan 09 '12 at 13:22
  • 4
    Possibly due to POSTing more data than the `post_max_size`? Have a look at http://stackoverflow.com/questions/8573664/php-empty-post for more info. – cmbuckley Jan 09 '12 at 13:22
  • @MitchWheat surprisingly, not even experts know everything – JamesHalsall Jan 09 '12 at 13:23
  • What kind of form elements are used in this form? Can you post any of the code? – DampeS8N Jan 09 '12 at 13:24
  • @MitchWheat nowhere, was just a comment... experts only become experts because they seek the right help when they are stuck (which you could argue is what Haluk is doing). Getting an "expert" to sort all the problems you can't solve gets you nowhere in the long run – JamesHalsall Jan 09 '12 at 13:26
  • @Jaitsu : that is fallacious logic. – Mitch Wheat Jan 09 '12 at 13:27
  • It is sounds more like headers problem or configuration issue. I don't think switch to PHP 5.3 will resolve it. – YuS Jan 09 '12 at 13:27
  • @MitchWheat that's just my own experience, and I am speaking from a personal development perspective. If you want to improve, you have to understand the issue and understand the solution, no? – JamesHalsall Jan 09 '12 at 13:28
  • I'll be glad to provide any info you might ask. I understand the initial reaction is to check for post_max_size and other main parameters. We have already checked for many angles on this problem including post_max_size. But let me share them promptly. – Haluk Jan 09 '12 at 13:32
  • post_max_size is 20MB. The content posted was checked using $_GET submitting the same variables at the same time. Content is valid. – Haluk Jan 09 '12 at 13:40
  • @Haluk: How exactly are you relaying `$_GET` and `$_POST` contents to the action pages? – FtDRbwLXw6 Jan 09 '12 at 13:43
  • @drrcklsn as an example, form action is like this ="submit.php?sender_id=1" and form method is POST, as a hidden variable sender_id is sent as well. $_GET arrives at the submit.php without any problems. $_POST arrives without any variables in it. – Haluk Jan 09 '12 at 14:12
  • @Haluk check if the error occur when the person after the submit is finished, the person press refresh button resending the POST? – Ismael Jan 09 '12 at 15:56
  • @Ismael We can try disabling the submit button once it's pressed. Let's try that and I'll post its result. – Haluk Jan 09 '12 at 17:54
  • @Haluk disable button prevents double click, but do not prevents people to click on refresh button or press F5 key, which do the same. The data are resent to serve. In opera browser case, the post is resent without asking if the person really want to do it. Maybe this is not the problem, but you can eliminate one doubt at least. – Ismael Jan 10 '12 at 10:06
  • possible duplicate of [Why does Internet Explorer not send HTTP post body on Ajax call after failure?](http://stackoverflow.com/questions/4796305/why-does-internet-explorer-not-send-http-post-body-on-ajax-call-after-failure) – Haluk Jan 04 '15 at 21:54

2 Answers2

0

Adding
<?php header("Connection: close"); ?>
cleared the problem on our end. Apparently this relates to keep-alive and IE. You can read more about it here: Why does Internet Explorer not send HTTP post body on Ajax call after failure?

Community
  • 1
  • 1
Haluk
  • 2,091
  • 2
  • 27
  • 35
0

Could it be that some sort of input to the form makes the sending fail, or, assuming you judge the 1-2% by empty database entries, makes the storing fail, respectively?

[edit] That sounds stupid... What I meant was, if you have a loop submitting the form 1000 times with the same values, does 1-2% still go empty, or could it be up to what is sent, that the form goes empty?

kontur
  • 4,934
  • 2
  • 36
  • 62
  • We catch empty $_POST's before submitting them to the database. But we get notified by email about the error and technical details about it. – Haluk Jan 09 '12 at 13:41
  • Is there anything worth mentioning in the "technical details" of those failed sends? What code do you use to determine the error? – kontur Jan 09 '12 at 13:43
  • We get the user info from the session. To see if the session is active. We get SERVER_CONTENT_LENGTH. This comes out empty if the post is empty. We also check SERVER_REQUEST_URI to see if get variables are in the url. – Haluk Jan 09 '12 at 14:09
  • I suppose you refer to `$_SERVER['REQUEST_URI']` and content_length. Judging from the later, you are uploading files - is it possible certain file input causes the send to fail (wrong mime types, extensison, file sizes, ...)? Don't be shy to post code in your question, either - it makes finding possible errors a lot easier :) – kontur Jan 09 '12 at 14:28
  • No this is not a file upload. Just simple text area. Yes let me share the code. – Haluk Jan 09 '12 at 14:31
  • Ah, of corse, content_length goes with post, not just file uploads. Thanks for showing the code - I don't see anything poking out there. Do you think you could share the receiving end code also, to see if maybe there would be an answer as to why the post values are missing at times? Also, is the submit.php using forwarding to another page after form processing, or is it a webpage that can be refreshed? – kontur Jan 10 '12 at 07:56