在PHP 5.2.6 / IIS CGI中清空$ _POST数组 [英] Empty $_POST array in PHP 5.2.6 / IIS CGI

查看:135
本文介绍了在PHP 5.2.6 / IIS CGI中清空$ _POST数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个非常奇怪的问题,在Windows XP上使用PHP 5.2.6 w / IIS(已尝试过CGI和ISAPI)。我正在使用默认的php.ini设置运行全新安装。



首先,假设以下(丑陋但有效)HTML代码:

 < form action =<?php echo $ _SERVER ['PHP_SELF'];?>方法= POST > 
< input type =hiddenname =test1value =foo/>
< input type =hiddenname =test2value =bar/>
< input type =submit>
< / form>
< br />< br />
< pre>
<?php print_r($ _ POST); ?>
< / pre>

提交表单时,我希望它能够显示一个包含两个隐藏变量的数组。相反,我看到的只是一个空数组。如果我将form方法更改为get并将print_r($ _ POST)更改为print_r($ _ GET),我会看到没有问题的数组项。



我有尝试过变种,例如<?php print file_get_contents('php:// input'); ?> <?php echo print_r($ HTTP_POST_VARS); ?> 无济于事。问题可能存在的任何想法?

解决方案

好吧,如果有任何安慰,你的代码可以在PHP5中与Apache一起工作。<一个快速的谷歌透露了一些其他人有同样的问题,但没有明确的解决方案 - 最接近的事情是 b

/ 389664-_post-problem-php5-iisrel =nofollow noreferrer>这个 ...


检查你的IIS配置并查看PHP允许的动词。
我的猜测是不包括POST。你应该至少启用GET和POST
,或者只是让你的生活轻松并允许所有动词。


制作如果找到解决方案,请务必更新您的问题;我相信其他人会受益。


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?

解决方案

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.

这篇关于在PHP 5.2.6 / IIS CGI中清空$ _POST数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆