我一直在浏览互联网,但我找不到任何类似的帖子。
问题是我总是使用filter_input(INPUT_SERVER, "REQUEST_METHOD");
来获取表单是否已提交,但今天我正在开发一个登录系统,在使用PHP时行为奇怪,在这里你有我实际使用的代码:
$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: name@domain.com)">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 :(得分:0)
这是由于您的PHP版本确保您是5.5.15或以上
我认为你应该参考PHP filter_input(INPUT_SERVER, 'REQUEST_METHOD') returns null?