2017-01-07 41 views
0

我一直在寻找通过互联网,我还没有找到任何类似的线程。 问题是我一直使用filter_input(INPUT_SERVER, "REQUEST_METHOD");来获取表单是否已经提交,但是今天我开发了一个登录系统,在使用PHP时奇怪的行为,在这里你有我的代码实际使用:检查提交的表单(方法POST)不起作用

$email = filter_input(INPUT_POST, "email"); 
$pass = filter_input(INPUT_POST, "pass"); 

print "done0"; 
if(filter_input(INPUT_SERVER, "REQUEST_METHOD") != "POST") { 
    return; 
} 
print "done1"; 
if(!isset($email) || !isset($pass)) { 
    return; 
} 
print "done2"; 

和HTML之一:

<form action="#" method="POST" accept-charset="UTF-8" autocomplete="off" class="col s12"> 

    <div class="row"> 
     <div id="login-panel"> 

      <div class="col s12"> 
       <h2 class="white-text center-align">System sign-in</h2> 
      </div> 
      <div class="input-field col s12"> 

       <i class="material-icons prefix white-text">email</i> 
       <input type="email" name="email" class="validate white-text" autofocus required> 
       <label for="email" id="email-label" 
         data-error="You must provide a correct email (example: [email protected])">Your email</label> 

      </div> 
      <div class="input-field col s12"> 

       <i class="material-icons prefix white-text">visibility_off</i> 
       <input type="password" name="password" class="validate white-text" required> 
       <label for="pass">Your password</label> 

      </div> 
      <div class="input-field col s12"> 
       <button class="btn waves-effect waves-light" id="login-button" type="submit" name="action">Submit 
        <i class="material-icons right">send</i> 
       </button> 
      </div> 

     </div> 
    </div> 

</form> 

最后,我使用了兑现API的JQuery 2.1.1

希望有人能帮助我,谢谢!

+0

与此代码会发生什么? – chris85

回答