2015-10-30 73 views
2

我有一個簡單的HTML表單,它實際上在我的本地主機和少數服務器上運行良好。但是上次我把它放在我的代碼中,我明白它不會用POST發送數據,雖然我寫了method="post"。這是我第一次遇到這個問題,而且我不知道它是來自我身邊還是來自服務器。 當我轉儲GLOBAL帕拉姆$_SERVER在我的本地主機,參數REQUEST_METHODPOST,但當我轉儲它在服務器上它是GET。我也試圖改變.htaccess中的方法,但沒有結果。 這裏是我的形式:Php表單發佈方法不發送數據

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

就當我打印$_POST$_POST['login']它們是空的,雖然我已經通過PARAMS服務器。

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>"; 
} 

是從服務器還是託管配置?

+0

你可以使用任何框架???或者核心php? –

+0

我正在使用Kohana框架,並且我已經爲其他幾個項目使用sam e代碼,它工作得很好,這個項目和代碼也在我的本地服務器上工作,但它不會在當前服務器上發送POST數據。我的問題是,如果可以從服務器配置? –

回答

-1

試試這個

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

對不起,但它不起作用。輸入類型圖像與提交類似。所以結果是一樣的。 –

+0

我已經測試了這個和它的工作 – Ricky

+0

在你的動作改變這個/ auth /登錄到這個驗證/登錄 – Ricky

-1

你缺少關鍵字:類型= 「提交」

+0

而不是提交我正在使用type =「圖像」這是類似於submit.I也嘗試過提交,但結果是相同的 –