我是php的新手。我只是想问一下如何将登录失败消息显示为POPUP而不是新页面。我应该在命令" print
"?
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
// Get member ID into a session variable
$id = $row["id"];
session_register('id');
$_SESSION['id'] = $id;
// Get member username into a session variable
$username = $row["username"];
session_register('username');
$_SESSION['username'] = $username;
// Update last_log_date field for this member now
mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'");
// Print success message here if all went well then exit the script
header("location: member_profile.php?id=$id");
exit();
} // close while
} else {
// Print LOGIN FAILURE MESSAGE to the user and link them back to your login page
print '<br /><br /><font color="#FF0000">No match in our records, try again </font> <br />
<br /><a href="login.php">Click here</a> to go back to the login page.';
exit();
}
答案 0 :(得分:1)
您必须使用javascript警报或一些jquery自定义弹出窗口。
有一个jquery插件Impromptu,您可以在其中显示自定义弹出窗口。它还有其他功能。
您可以显示以下显示的登录失败消息以及返回上一页的回调:
$.prompt('Login Failed',{
close: function(){
window.location.href = "page_url";
}
});
有关详细信息,请参阅this link