<?php
// 弹出对话框并且返回原来的页面
echo "<script language=\"JavaScript\">\r\n";
echo " alert(\"你好\");\r\n";
// 历史返回;
echo " history.back();\r\n";
echo "</script>";
exit;
?>
<!-- php弹窗,是利用javascript -->
<?php
echo "<script language=\"JavaScript\">alert(\"你好\");</script>";
?>
<!-- php弹窗,是利用javascript -->
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script>
function del(){
if(confirm("确定要删除吗?")){
alert('删除成功!');
return true;
}else{
return false;
}
}
</script>
</body>
</html>
<?php
$button=<<<STR
<button onclick="del()">删除</button>
STR;
echo $button;
?>
<?php
$user=$_POST["user"];
$pwd=$_POST["pwd"];
if(strlen($user)==0){
alert("请输入用户名",'login.php');
exit;
}
if(strlen($pwd)==0){
echo '请输入密码';
exit;
}
if($user=="admin" && $pwd==123456){
echo '登录成功';
}else{
echo '用户名或密码错误';
}
function alert($str,$url){
echo '<script>alert("'.$str.'");location.href="'.$url.'"</script>';
}
?>