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 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。