简体   繁体   English

PHP表格过帐方法不发送数据

[英]Php form post method not sending data

I have a simple HTML form, which is actually working well on my localhost and in few servers. 我有一个简单的HTML表单,该表单实际上在我的localhost和少数服务器上都能正常工作。 But last time I put it in my code, I understood that it doesn't send data with POST , although I have written the method="post" . 但是上次我将其放入代码中时,虽然我已经编写了method="post" ,但我知道它不会通过POST发送数据。 This is first time I meet this problem, and I don't know if it is from my side or from server. 这是我第一次遇到此问题,并且我不知道这是从我这边还是从服务器。 When I dump GLOBAL param $_SERVER in my localhost, the param REQUEST_METHOD is POST , but when I dump it on server it is GET . 当我在本地主机中转储GLOBAL参数$_SERVER时,参数REQUEST_METHODPOST ,但是当我将其转储到服务器上时是GET I also tried to change the method in .htaccess , but no result. 我也尝试更改.htaccess的方法,但没有结果。 Here is my form: 这是我的表格:

<form action="/auth/login" method="post">
      <div id="error">
            <?
              if (isset($errors)) {
                 foreach ($errors as $error) {
                      echo $error . "<br>";
                  }
               }
               if (isset($invalid)) {
                    echo $invalid;
                }
               ?>
      </div>
      <div id="login-box-name" style="margin-top:20px;">Login:</div>
      <div id="login-box-field" style="margin-top:20px;">
           <input name="login" class="form-login" type="text"/>
       </div>
       <div id="login-box-name">Password:</div>
       <div id="login-box-field">
            <input name="password" type="password" class="form-login"/>
        </div>
        <br />
        <input type="image" src="/images/login-btn.png" width="103" height="42" style="margin-left:90px;" />
   </form>

And on server when I print $_POST or $_POST['login'] they are empty, although I have passed params. 在服务器上,当我打印$_POST$_POST['login']它们是空的,尽管我已经传递了参数。

 public function action_login() {  
        echo "<pre>";
        var_dump($_SERVER); // this is returns server data, where REQUEST_METHOD is GET on current server, but POST in my local 
        var_dump($_POST); // this is empty
        echo "</pre>";
}

Is that from server or hosting configuration? 是服务器还是主机配置?

Try this 尝试这个

<form action="auth/login" method="POST">
          <div id="error">
                <?
                  if (isset($errors)) {
                     foreach ($errors as $error) {
                          echo $error . "<br>";
                      }
                   }
                   if (isset($invalid)) {
                        echo $invalid;
                    }
                   ?>
          </div>
          <div id="login-box-name" style="margin-top:20px;">Login:</div>
          <div id="login-box-field" style="margin-top:20px;">
               <input name="login" class="form-login" type="text"/>
           </div>
           <div id="login-box-name">Password:</div>
           <div id="login-box-field">
                <input name="password" type="password" class="form-login"/>
            </div>
            <br />
            <input type="submit" src="/images/login-btn.png" width="103" height="42" style="margin-left:90px;" value="save" />
       </form>

您缺少关键字:type =“ submit”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM