$_POST可以在本地主机中传递数据,但不能在活动服务器中传递


$_POST can pass data in localhost, but not in live server

我确实试图解决这个问题,但没有成功。在我的网站上,我有两个基本的表格。一个用于登录,一个用于注册。当我在Apache中测试代码时,它运行得非常好。表单可以将输入传递到另一个php页面并执行检查。但当我把代码移到托管服务器上时,表单无法传递任何数据(我确保输入了这些字段)。我真的不知道我做错了什么。Apache中的PHP版本是5.4.7,而托管中的PHP版本是5.2.17。以下是表格代码:

<form action="register_check.php" method="post" style="text-align:center">
    <input type="text" name="username" class="form-control" autocomplete="off" placeholder="Username"/>     
    <input type="password" name="password" class="form-control" placeholder="Password"/>
    <input type="password" name="password_again" class="form-control" placeholder="Please type the password again"/>
    <input type="text" name="email" class="form-control" placeholder="Email"/><br/>
    <input type="hidden" name="token" value="">
    <input type="submit" name="register" class="btn btn-primary"/>
</form>
<form action="login_check.php" method="post" style="text-align:center">
    <input type="text" name="username" class="form-control" autocomplete="off" placeholder="Username"/>
    <input type="password" name="password" class="form-control" placeholder="Password"/>
    <input type="hidden" name="token" value="">
    <label 
            <input type="checkbox" name="remember" id="remember"> Remember Me 
    </label>
    <input type="submit" name="login" class="btn btn-primary"/>
</form>

当我在Apache中进行本地测试时,数据能否成功传递到register_check.php或login_check.php取决于我按下了哪个按钮。为了确保数据能够通过,我在register_check.php和login_check.php上都写了这篇文章:

var_dump($_POST);
die();

即使我没有在字段中键入任何内容,我也得到了一个数组:

array(6){["username"]=>string(0)"["password"]=>字符串(0)

但现在我开始头疼了。我把完全相同的代码移到了我的托管服务器上。我在表格里什么也没打,按了提交键。var_dump给了我这个结果:

数组(0){}

即使我在输入字段中键入了一些内容,它仍然会给我返回相同的结果:

数组(0){}

我真的不知道哪里出了问题。之前我怀疑php版本5.2.17可能太旧了,但对我来说这有点不可能,因为这只是一个表单处理。

所以我希望有人能告诉我出了什么问题。我因为这个奇怪的问题睡不着。非常感谢!

您的实时服务器上有.htaccess吗?如果是,请尝试删除它,然后再次发送您的数据。

检查实时服务器的配置。Apache的基本配置是用于开发,因此几乎所有功能都已启用。也许您的Live Server有一项重要功能被阻止。