I am using jQuery Mobile 1.4, and i have a login form. I want to show a popup when username and password are wrong and go to another page when succeeds. The problem is that popup is showing even when succeed, any time i click "login"
$user = isset($_POST['uName']) ? strtolower($_POST['uName']) : '';
$pass = isset($_POST['uPass']) ? $_POST['uPass'] : '';
if (!isset($logins[$user]) or $logins[$user] != $pass) {
echo "<script language=Javascript>
$(document).ready(function() {
$('#login-form').on('submit',function(e) {
e.preventDefault();
$('#popup').popup({ overlayTheme: 'b' });
$('#popup').popup('open');
});
});
</script>";
} else {
echo "<script language=Javascript>
document.location.href='flow.php';
</script>";
}
$logins = array(
'username2' => 'password2',
'username3' => 'password3',
);
?>
<div data-role="main" id="page-content-ajax" class="ui-content jqm-content jqm-fullwidth ">
<div role="main" class="ui-content jqm-content">
<form action="" id="login-form" method="POST" />
<input name="uName" type="text" placeholder="Username" />
<input name="uPass" type="password" />
<button type="submit" id="btn-login" class="ui-btn ui-btn-active ui-btn-icon-right ui-icon-arrow-r" >Login</button>
</form>
</div>
<div data-role="popup" id="popup" data-overlay-theme="b" data-theme="b" style="max-width:400px;">
<div data-role="header" data-theme="a">
<h1>Warning!</h1>
</div>
<div role="main" class="ui-content">
<h3 class="ui-title">Wrong username or password</h3>
<a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back" data-transition="flow">Ok</a>
</div>
</div>
</div>
Try to change:
if (!isset($logins[$user]) or $logins[$user] != $pass) {
to:
if (!isset($logins[$user]) || $logins[$user] != $pass) {
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.