当用户输入重复的电子邮件或用户名时,我遇到显示模式的问题,我已经定义了一个布尔值,以便在显示模态时存储为true,否则为false。即使我输入新的用户名和电子邮件,模式仍然显示,我真的很困惑为什么。
PHP:
if($checkUser->rowCount() > 0 || $checkEmail->rowCount() > 0){
$showModal = true;
}else{
$showModal = false;
HTML:
<?php if($showModal===false): ?>
<input type="submit" id="submit" name="submit" value="Register" readonly="readonly"/>
<?php else: ?>
<input type="" id="submit" name="submit" data-toggle="modal" data-target="#myModal" value="Register" readonly="readonly"/>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Registration Error!</h4>
</div>
<div class="modal-body">
<p>You have entered a Username or Email Address which has already been registered!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php endif; ?>
我从模态输入中删除了“提交”类型,因为它导致模式在页面刷新时中断。
感谢任何帮助,谢谢。