PHP $ _POST无法正常工作,但$ _GET正常工作 [英] PHP $_POST not working but $_GET works fine

查看:107
本文介绍了PHP $ _POST无法正常工作,但$ _GET正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用< form method =post> 来构建简单的登录系统。一切工作正常我的笔记本电脑上的MAMP,但是当我上传脚本到服务器(Windows)它不工作;看起来$ _POST数组是空的。



我评论了一切,但裸露的骨头,它仍然无法正常工作。



index.php:

 < form id =login-formmethod =POSTaction = _脚本/ check_login.php > 
电子邮件地址
< input name =login-emailtype =textid =login-email>
密码
< input name =login-passwordtype =textid =login-password>
< input type =submitname =Submitid =login-buttonvalue =Login>
< / form>

_scripts / check_login.php:(我已经删除了一些var_dumps以进行调试)

  var_dump($ _ POST); 

$ loginEmail = trim($ _ POST ['login-email']);
echo'< br>';
$ loginPassword =($ _POST ['login-password']);
var_dump($ loginEmail);
echo'< br>';
var_dump($ loginPassword);

当我提交表单时,无论我在文本字段中输入什么,我都会看到:

  array(0){} 
string(0)
NULL
code>

如果我在上述两个文件中将post的所有实例更改为get,则一切正常。但我不想用get。 ($ _REQUEST不起作用,或者如果我使用method =post提交表单)。



注意,这一切在localhost上工作正常,但不在服务器上这是运行Windows。)所以这似乎是服务器的问题,但我不知道是什么。你可以在这里看到PHPInfo: http://brailleapps.org/phpinf0.php



有什么想法?

编辑:已解决!见下面。

解决方案

我最终修正了这个问题,问题。



原来这些HTTP模块中有一个干扰了POST:

RadCompression

RadUploadModule



在这些模块关闭的情况下,POST工作正常。



一个全新的应用程序,我知道没有任何现有的代码可能取决于其中的一个模块...关闭它们可能会产生意想不到的后果,YMMV。)


I'm trying to build a simple login system using <form method="post">. Everything works fine on MAMP on my laptop but when I upload the script to the server (Windows) it doesn't work; it seems that the $_POST array is empty.

I commented out everything but the bare bones and it still doesn't work.

index.php:

<form id="login-form" method="POST" action="_scripts/check_login.php">
Email Address
<input name="login-email" type="text" id="login-email">
Password
<input name="login-password" type="text" id="login-password">
<input type="submit" name="Submit" id="login-button" value="Login">
</form>

_scripts/check_login.php: (I've removed everything except some var_dumps for debugging)

var_dump($_POST);

$loginEmail = trim($_POST['login-email']);
echo '<br>';
$loginPassword = ($_POST['login-password']);
var_dump($loginEmail);
echo '<br>';
var_dump($loginPassword);

When I submit the form, no matter what I put in the text fields, I see this:

array(0) { }
string(0) ""
NULL

If I change all the instances of "post" to "get" in the above two files, everything works fine. But I don't want to use get. ($_REQUEST doesn't work either if I submit the form using method="post").

NB this all works fine on localhost, but not on the server (which is running Windows.) So it would seem to be a problem with the server, but I have no idea what. You can see the PHPInfo here: http://brailleapps.org/phpinf0.php

Any ideas?

EDIT: Solved! See below.

解决方案

I got it fixed eventually, figure I might as well post what worked here in case someone else has the same problem in future.

Turns out one of these HTTP modules was interfering with POST:

RadCompression
RadUploadModule

With these modules turned off, POST worked fine.

(NB this was on a totally new app where I knew there wasn't any existing code that might have depended on one of those modules... turning them off may have unintended consequences I'm not aware of, YMMV.)

这篇关于PHP $ _POST无法正常工作,但$ _GET正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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