首页 / PHP / PHP isset函数提交检查不起作用
PHP isset函数提交检查不起作用
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PHP isset函数提交检查不起作用,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4148字,纯文字阅读大概需要6分钟。
内容图文
![PHP isset函数提交检查不起作用](/upload/InfoBanner/zyjiaocheng/770/98861e2a8d6548c88845dcf536148ecb.jpg)
我刚刚发现isset函数不再适用于我的登录和注册表单.我很奇怪,所以我解除了我最近所做的一切,看它是不是造成了它,但没有运气.如果我删除了isset并替换为此;
if($_SERVER['REQUEST_METHOD'] == "POST"){
有用!但是我在一个页面上有两个表单,所以我需要检查哪个表单已提交.
这是isset函数:
if (isset($_POST['submit_login'])) {
并且提交按钮只是让您知道它具有正确的名称;
<input type="submit" name="submit_login" value="Login" class="buttonClassic"/>
注册表单的名称完全相同,但名称为submit_reg.
形成:
<form action="<?php echo htmlentities('Login'); ?>" method="post" id="login">
<p class="p1">Already signed up? Log in</p><hr/>
<label for="email">Your email address </label><input type="email" required name="email" placeholder="Email" class="text" id="email">
<label for="password">Your password </label><input type="password" name="pass" required placeholder="Password" class="text" id="password">
<center><input type="submit" name="submit_login" value="Login" class="buttonClassic"/></center>
<div class="center-align-text">
<p class="p3"><a href="passreset.html">Forgotten your password?</a></p>
</div>
</form>
注册表格:
<form action="<?php echo htmlentities('Login'); ?>" method="post" id="register" >
<p class="p1">New to NBS? Sign up, it's free!</p><hr/>
<label for="reg_email">What's your email address? </label><input type="email" name="email" required placeholder="Email" class="text" id="reg_email">
<label for="reg_password">Choose a password </label><input type="password" required name="pass" placeholder="Password" class="text" id="reg_password">
<label for="reg_password2">Re-type password </label><input type="password" required name="pass2" placeholder="Re-type password" class="text" id="reg_password2">
<input type="checkbox" name="subscribed" value="subscribed" id="subscribed"><label for="subscribed">Yes, send me email updates from NewBorn Sounds. </label>
<br/>
<input type="checkbox" required="flag" name="terms" value="ticked" id="terms"><label for="terms">I agree to the <a href="Terms">terms & conditions</a>.</label>
<center><input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic"></center>
</form>
如果你需要更多的东西只是喊!
哦,我知道我可以将表单提交给外部PHP脚本,但我并不特别想这样做,因为我希望将用户输入错误输出到同一页面.我知道我可以使用ajax,我这样做,但我试图将javascript作为一个附加组件,而不是减少没有js的用户体验.
完整的HTML:
<div id="login_form_wrapper">
<form action="Login" method="post" id="login" novalidate="novalidate">
<p class="p1">Already signed up? Log in</p><hr>
<label for="email">Your email address </label><input type="email" required="" name="email" placeholder="Email" class="text" id="email">
<label for="password">Your password </label><input type="password" name="pass" required="" placeholder="Password" class="text" id="password">
<center><input type="submit" name="submit_login" value="Login" class="buttonClassic"></center>
<div class="center-align-text">
<p class="p3"><a href="passreset.html">Forgotten your password?</a></p>
</div>
</form>
<form action="Login" method="post" id="register" novalidate="novalidate">
<p class="p1">New to NBS? Sign up, it's free!</p><hr>
<label for="reg_email">What's your email address? </label><input type="email" name="email" required="" placeholder="Email" class="text" id="reg_email">
<label for="reg_password">Choose a password </label><input type="password" required="" name="pass" placeholder="Password" class="text" id="reg_password">
<label for="reg_password2">Re-type password </label><input type="password" required="" name="pass2" placeholder="Re-type password" class="text" id="reg_password2">
<input type="checkbox" name="subscribed" value="subscribed" id="subscribed"><label for="subscribed">Yes, send me email updates from NewBorn Sounds. </label>
<br>
<input type="checkbox" required="flag" name="terms" value="ticked" id="terms"><label for="terms">I agree to the <a href="Terms">terms & conditions</a>.</label>
<center><input type="submit" name="submit_reg" value="Sign Up" class="buttonClassic"></center>
</form>
</div>
解决方法:
也许你可以这样做:
if($_SERVER['REQUEST_METHOD'] == "POST"){
if (isset($_POST['submit_login'])) {
//do something
} else {
//do something else
}
}
内容总结
以上是互联网集市为您收集整理的PHP isset函数提交检查不起作用全部内容,希望文章能够帮你解决PHP isset函数提交检查不起作用所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。