Posting from IE8 to PHP gives blank $_POST

前端 未结 5 677
失恋的感觉
失恋的感觉 2021-01-13 01:05

I have a simple HTML form, sending a post request to a php script. In IE8, the form only works intermittently - most of the time the PHP script sees an empty $_POST variable

相关标签:
5条回答
  • 2021-01-13 01:46

    I'm suspicious that when the script is telling you that $_POST is empty, you did not actually POST the form. You can check by adding print($_SERVER['REQUEST_METHOD']); after your print_r($_POST);

    0 讨论(0)
  • 2021-01-13 01:52

    That sounds very very bizarre. Does it happen in other versions of IE as well?

    I can't tell you what the problem is, but here are my suggestions on how to diagnose it:

    1. Print $_REQUEST rather than just $_POST, to see if the data is coming in via another method.

    2. Use a tool like Fiddler or Wireshark to track exactly what is actually being sent by the browser.

    Fiddler in particular has been very helpful for me a few times (mainly when debugging Ajax code), and will tell you exactly what was posted by the browser. If your web server is localhost, you can also use Fiddler to track what is received before PHP gets its hands on it. If not, you can use wireshark on the server if you have permissions for installing that sort of thing.

    In addition to Fiddler, I would have suggested a browser-based tool like Firebug, but I don't know of one for IE that is good enough (The IE dev toolbar doesn't give you details of request and response data, as far as I know).

    0 讨论(0)
  • 2021-01-13 01:52

    Have you checked the generated html? Is it possible that echo $_SERVER['PHP_SELF'] isn't producing the output you're after, which messes up the form html, which messes up the POST?

    0 讨论(0)
  • 2021-01-13 01:54

    If you are posting a file some of the time (i.e. with a file input) then make sure you set enctype="multipart/form-data" in your <form> element.

    0 讨论(0)
  • 2021-01-13 01:57

    Thanks everyone for wading in on this one.

    It turns out the problem lay in an Apache module I had enabled.

    It's a module to allow apache to use Windows authentication to identify a user via their Windows User id - mod_auth_sspi

    The effect is caused by a known bug, in the module, but with a simple extra directive this can be worked around, until a fix is added in the next update, as described here:

    http://sourceforge.net/projects/mod-auth-sspi/forums/forum/550583/topic/3392037

    0 讨论(0)
提交回复
热议问题