tags:

views:

992

answers:

2

I am running into a very strange issue with PHP 5.2.6 w/ IIS on Windows XP (have tried both CGI and ISAPI). I am running a fresh installation with the default php.ini settings.

First, assume the following (ugly, but effective) HTML code:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="test1" value="foo" />
<input type="hidden" name="test2" value="bar" />
<input type="submit">
</form>
<br /><br />
<pre>
<?php print_r($_POST); ?>
</pre>

When the form is submitted, I expect it to bring out an array containing the two hidden variables. Instead all I see is an empty array. If I change the form method to "get" and change print_r($_POST) to print_r($_GET), I see the array items with no problem.

I have tried variations such as <?php print file_get_contents('php://input'); ?> and <?php echo print_r($HTTP_POST_VARS); ?> to no avail. Any ideas where the problem might lie?

+2  A: 

Well, if it's any consolation your code works as intended in PHP5 with Apache.

A quick Google revealed a couple other people with the same problem but no definitive solution - closest thing was this...

Check your IIS configuration and see what verbs are permitted for PHP. My guess is that POST isn't included. You should have GET and POST enabled at a minimum, or just make your life easy and allow all verbs.

Make sure you update your question if you find a solution; I'm sure other people will benefit.

Flubba
Thanks Flubba, but I have all verbs enabled in IIS. Still unable to receive POST vars in PHP.
giltotherescue
A: 

Actually, I'm having the same issue with PHP5 on Apache 2. The weirdest part is that this is a server that's been working for well over a year, and it just suddenly ate itself last night. The same script will work on a different system with an identical Apache/PHP config, so I know my code works. So if either of you get a clue as to WTF is causing this, I'd be hugely appreciative of a follow-up.