Javascript 如何在php中显示登录屏幕中的警报框。如果用户输入';这段代码的密码或用户名有误
如何在php中显示登录屏幕中的警报框 如果用户为此代码输入了错误的密码或用户名Javascript 如何在php中显示登录屏幕中的警报框。如果用户输入';这段代码的密码或用户名有误,javascript,php,html,Javascript,Php,Html,如何在php中显示登录屏幕中的警报框 如果用户为此代码输入了错误的密码或用户名 if(isset( $_POST['email'])){ $email = $_POST['email']; $cpassword = $_POST['cpassword']; include ("../backend/user.php"); $c = new customer(); //Assign username & password from post met
if(isset( $_POST['email'])){
$email = $_POST['email'];
$cpassword = $_POST['cpassword'];
include ("../backend/user.php");
$c = new customer();
//Assign username & password from post method to a varibale
$res = $c->customer_login($email,$cpassword);
if($res == true){
//Direct the user to appropriate page
header("location:../views/profile.php");
}else{
include ("../backend/admin.php");
$a = new admin();
//Assign username & password from post method to a varibale
$res = $a->admin_login($email,$cpassword);
if($res == true){
//Direct the user to appropriate page
header("location:../views/admin.php");
}
}
//Display message invalid user name or password
$message = "invalid username or password";
}
您可以使用Javascript: $message=“无效的用户名或密码”
echo“警报('$message')
php在服务器上运行-您不能在服务器上发出警报(php无论如何都没有警报功能)并期望客户端在浏览器中看到警报是的,您可以通过在phpCheck登录php AJAX中注入javascript代码为例
echo "<script type='text/javascript'>alert('$message');</script>"