douju5933 2013-12-02 12:38
浏览 10
已采纳

$ _POST可以在localhost中传递数据,但不能在实时服务器中传递数据

I really tried to figure out this problem but did not success. In my website, I have 2 basic forms. One for log in and one for registration. When I was testing the code in Apache, it was working wonderful. The forms can pass the inputs to another php page and perform checks. But when I moved the code to a hosting server, the form could not pass any data (I made sure I typed in those fields.) I really ran out of ideas what I have done wrong. The PHP version in Apache is 5.4.7, and the php version in hosting is 5.2.17. Below is the code of the forms:

<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>

When I was testing in Apache locally, the data could successfully pass to register_check.php or login_check.php depends on which button I pressed. To make sure the data was able to pass through, I wrote this on both register_check.php and login_check.php:

var_dump($_POST);
die();

Even when I typed nothing into the fields, I got an array back:

array(6) { ["username"]=> string(0) "" ["password"]=> string(0) "" ["password_again"]=> string(0) "" ["email"]=> string(0) "" ["token"]=> string(0) "" ["register"]=> string(6) "Submit" }

But now my headache begins. I moved the exactly same code to my hosting server. I typed nothing in the form, and pressed submit. The var_dump gave me back this result:

array(0) { }

and even when I typed something into the input fields, it still gave me back the same result:

array(0) { }

I really ran out of ideas what could have went wrong. Before I was suspecting the php version 5.2.17 might be too old, but to me that is kinda impossible cause this is just a form processing.

So I hope somebody can tell me what is wrong. I couldn't sleep because of this weird problem. Thank you so much!

  • 写回答

2条回答 默认 最新

  • dongzhi2014 2013-12-02 12:56
    关注

    Is there a .htaccess on your live server? If yes, try to delete it and send your data again.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧