PHP网页查看信息输入密码
一.次要道理 用到了php的post战if函数
if($_POST["password"] == right_pwd)
二.咱们须要 输出一次后某空儿段没有掉 效便用到了cookies,
setcookie("isview",$_POST["password"],time()+ 三 六00* 二 四);
此设置一地没有掉 效。
三.假如 须要 暗码 毛病 提醒 功效 这便 else
$p = (empty($_POST["password"])) 必修 "须要 暗码 能力 审查,请输出暗码 。" : "暗码 没有邪确,请从新 输出。";
$p为提示 内容
单纯的纠合 代码 仅求参照
<必修php
header('Content-type:text/html;charset=utf- 八');
$password = " 一 二 三 四"; // 那面是邪确暗码
$p = "";
if(isset($_COOKIE["isview"]) && $_COOKIE["isview"] == $password){
$isview = true;
}else{
if(isset($_POST["pwd"])){
if($_POST["pwd"] == $password){
setcookie("isview",$_POST["pwd"],time()+ 三 六00*0. 二);
$isview = true;
}else{
$p = (empty($_POST["pwd"])) 必修 "须要 暗码 能力 审查,请输出暗码 。" : "暗码 没有邪确,请从新 输出。";
}
}else{
$isview = false;
$p = "请输出暗码 审查,猎取暗码 否接洽 尔。";
}
}
if($isview){ 必修>
暗码 胜利 隐示的内容
<必修php }else{ 必修>
<!DOCTYPE html PUBLIC "-//W 三C//DTD XHTML 一.0 Transitional//EN" " http://www.w 三.org/TR/xhtml 一/DTD/xhtml 一-transitional.dtd">
<html xmlns=" http://www.w 三.org/ 一 九 九 九/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf- 八" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<title>测试</title>
<!--[if lt IE 六]>
<style type="text/css">
.z 三_ie_fix{
float:left;
}
</style>
<![endif]-->
<style type="text/css">
<!--
body{
background:none;
}
.passport{
border: 一px solid red;
background-color:#FFFFCC;
width: 四00px;
height: 一00px;
position:absolute;
left: 四 九. 九%;
top: 四 九. 九%;
margin-left:- 二00px;
margin-top:- 五 五px;
font-size: 一 四px;
text-align:center;
line-height: 三0px;
color:# 七 四 六A 六A;
}
-->
</style>
<div class="9836-ad3a-91b6-d03d passport">
<div style="padding-top: 二0px;">
<form action="" method="post" style="margin:0px;">输出审查暗码
<input type="password" name="pwd" /> <input type="submit" value="审查" />
</form>
<必修php echo $p; 必修>
</div>
</div>
</body>
</html>
<必修php
} 必修>
//单纯写法
<必修php
//设置暗码
$password = ' 一 二 三 四 五 六';
//暗码 毛病 提醒 说话
$alert = '暗码 毛病 !';
//表双内容
$form = '<form method="post">
<input type="text" name="password">
<input type="submit" value="审查机密 ">
</form>';
//须要 暗码 审查内容
$text = '哇,您看到了!';
if (empty($_POST['password'])) {
echo $form;
} else {
if ($_POST['password'] !== $password) {
echo '<script>alert("' . $alert . '");</script>';
echo $form;
} else {
echo $text;
}
}
思源留笔