因此,在用户成功登录到他/她的帐户后,他/她应该被定向到index.php并且Chrome在右上方显示了这个微小的通知
但是,当用户输入错误的电子邮件或密码时,Chrome在图片中也会显示相同的通知,但当然,他/她不会重定向到index.php。我怎么能告诉"该用户输入错误的电子邮件/密码的Chrome /用户?
$email = mysqli_real_escape_string($mysqli, $_POST["email"]);
$password = mysqli_real_escape_string($mysqli,$_POST["password"]);
//select all data by using email and password entered
$customers = $mysqli->query("select * from customer where CustomerEmail='".$email."' and CustomerPassword='".$password."'");
$customer = mysqli_num_rows($customers);
$managers = $mysqli->query("select * from manager where ManagerEmail='".$email."' and ManagerPassword='".$password."'");
$manager = mysqli_num_rows($managers);
$staffs = $mysqli->query("select * from staff where StaffEmail='".$email."' and StaffPassword='".$password."'");
$staff = mysqli_num_rows($staffs);
echo $customer.'<br>';
echo $manager.'<br>';
echo $staff.'<br>';
//if customer is true
if($customer== 1){
$row = mysqli_fetch_assoc($customers);
$id= $row['CustomerID'];
$email = $row['CustomerEmail'];
$name = $row['CustomerName'];
//start session
session_start();
//create session
$_SESSION['CustomerID'] = $id;
$_SESSION['CustomerEmail'] = $email;
$_SESSION['CustomerName'] = $name;
//redirect page to index.php
header("Location: index.php");
}
//if manager is true
else if($manager == 1){
$row = mysqli_fetch_assoc($managers);
$id = $row['ManagerID'];
$email = $row['ManagerEmail'];
$name = $row['ManagerName'];
//start session
session_start();
//create session
$_SESSION['ManagerID'] = $id;
$_SESSION['ManagerEmail'] = $email;
$_SESSION['ManagerName'] = $name;
//redirect page to managerCP.php
header("Location: managercp.php");
}
//if staff is true
else if($staff == 1){
$row = mysqli_fetch_assoc($staffs);
$id = $row['StaffID'];
$email = $row['StaffEmail'];
$name = $row['StaffName'];
//start session
session_start();
//create session
$_SESSION['StaffID'] = $id;
$_SESSION['StaffEmail'] = $email;
$_SESSION['StaffName'] = $name;
//redirect page to staffCP.php
header("Location: staffcp.php");
}
//if all condition is false
else {
//alert will be appeared
echo '<script language="javascript" type="text/javascript">alert("The combination of email and password do not match");document.location.href="index.php"</script>';
//header ("Location:index.php");
}
好。所以警报有效,但问题是显示白屏,我必须点击&#34;确定&#34;在重定向回index.php之前。我希望警报出现在index.php上。帮助