6

The following form causes an empty $_POST variable on IE9.

<form id='login' action='login.php' method='POST' accept-charset='UTF-8'>
<input type='text' name="username" id='username'  />
<input type='password' name='password' id='password' />
<input type="text" name="store" />
<input type='submit' name='Submit' value='Submit' />
</form>

The form works perfectly on Firefox and Chrome. All variables appear in the $_POST variable with no issues.

On IE9, however, the form is submitted properly, but $_POST is the empty array. I.e., in login.php:

print_r($_POST);

prints the empty array. I'm trying to figure out what could be different about IE9 that's making it behave differently from Firefox and Chrome and I can't figure it out.

I found mention of some module under Apache that's causing people problems, but I'm running IIS7, not Apache, so that's not it. Someone on a Ruby forum mentioned setting a DisableNTLMPreAuth to 1 in the registry, but that hasn't fixed it either.

Any help is appreciated.

JohannesAndersson
  • 4,550
  • 2
  • 17
  • 30
  • Try setting action to self and doing print_r there. Or is login.php what you are showing us? – Cole Tobin May 21 '12 at 14:47
  • 1
    Have you tried outputting phpinfo()? It would be interesting to see if any of the request variables are populating. For instance, $_REQUEST – Jonathan Barlow May 21 '12 at 14:47
  • 5
    open the developer-comsole on IE (pressing F12) and switch to the network-tab. now submit your form and take a look at the shown request: are the post-values mentioned there (wich means you problem is server-side) or are they missing (problem is client-side). – oezi May 21 '12 at 14:48
  • test your page with an HTML validator. – Karoly Horvath May 21 '12 at 14:49
  • I'd be curious what happens if you remove the `accept-charset` on the form. – Eric Petroelje May 21 '12 at 14:50
  • Is this really all the code? Put it in a separate file to test. I really can't believe a simple POST won't work, because your combination of IIS, PHP and IE is not quite unique: thousands would suffer from the same problem. – CodeCaster May 21 '12 at 14:51
  • check this http://www.redolivedesign.com/utah-web-designers-blog/2010/10/18/how-to-fix-utf-8charset-problem-with-iis-7-5-and-php-fastcgi/ – Venu May 21 '12 at 14:55
  • 4
    what's the output of `var_dump($_POST);` ? – Alex May 21 '12 at 14:56
  • 5
    Thanks for the ideas. Cheers especially for the IE developer console. I can see that a POST is sent for a split second (and I was quick enough that I could see the relevant input fields are being sent). A split second after the POST is sent, it loads the PHP page using a GET instead of a POST. I think we've narrowed down the problem to an http-equiv="refresh" which is going wrong on the target page. That's causing it to do a GET. Thanks everyone! – user1408141 May 21 '12 at 14:57
  • @user1408141 this perhaps : http://stackoverflow.com/questions/7096343/post-method-getting-converted-to-get-in-ie-9 – Manse May 21 '12 at 14:59
  • What happens if you enable compatibility mode in IE9? – Ben Swinburne May 21 '12 at 14:59
  • 5
    You could/should answer your question for yourself. Then accept your answer, so this is shown as answered and the solution is better documented and not hidden in the comments. – Krista K Jun 17 '12 at 20:09
  • I checked your script on my IE9. And it successfully post $_POST Variable. – Amrish Prajapati Jun 29 '12 at 04:53

4 Answers4

1

accept-charset is not support in Internet Explorer. Remove it and see if that solves you're problem.

Kao
  • 2,242
  • 3
  • 22
  • 31
0

I think this is to do with a double hit - i.e. that IE is re-reloading the page somehow. Have you got some client side stuff (jQuery?) that re-reloads the page by accident as a bug? Try posting to a completely new page and writing <?PHP die ('<pre>'.print_r($_REQUEST,true).'</pre>');?> on the top line and seeing what happens.

conners
  • 1,420
  • 4
  • 18
  • 28
-1

plz enter "name" attribute for form.

<form id='login'  name='login' action='login.php' method='POST' accept-charset='UTF-8'>
<input type='text' name="username" id='username'  />
<input type='password' name='password' id='password' />
<input type="text" name="store" />
<input type='submit' name='Submit' value='Submit' />
</form>
-1

The reason is you are not maintaining the session. In Firefox and Chrome are much smart and they maintain the session irrespective of the Development of the Code, which gives users a good things. But in IE6-9, IE Can't maintain session, developer has to check it and if the session is not maintained every page loaded is a new session and thus there is no post.

Vineet1982
  • 7,730
  • 4
  • 32
  • 67