有些时候我们网站内容只让指定的人看见。所以就需要密码访问。我百度上找了一下 都不咋好用,我这里发一个ui美化了的也是我自己用的
直接复制粘贴到需要加密的页面,就可以给网站开启了密码保护,让页面输入密码才能访问! 修改也非常简单,直接替换4行密码,替换48行要跳转的链接即可。 - <?php
- header('Content-type:text/html;charset=utf-8');
- $password = "zhidianyun"; // 这里是正确密码
- $p = "";
- if(isset($_COOKIE["isview"]) && $_COOKIE["isview"] == $password){
- $isview = true;
- }else{
- if(isset($_POST["pwd"])){
- if($_POST["pwd"] == $password){
- setcookie("isview",$_POST["pwd"],time()+3600*0.2);
- $isview = true;
- }else{
- $p = (empty($_POST["pwd"])) ? "需要密码才能查看,请输入密码。" : "密码不正确,请重新输入。";
- }
- }else{
- $isview = false;
- $p = "禁止访问";
- }
- }
-
- if($isview){ ?>
- <!DOCTYPE html>
- <html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="utf-8">
- <title>演示</title>
- <p>演示</p>
- </body>
- </html>
- <?php }else{ ?>
- <!DOCTYPE html>
- <html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="utf-8">
- <title>本站开启了验证码保护</title>
- <meta name="keywords" content="PHP加密">
- <meta name="description" content="PHP加密">
- <style type="text/css">
- html{background-color:#FFF}body,button,input{font:14px/20px "Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif}body{color:#585858;letter-spacing:1px}i{font-style:normal}p{margin:0}a{color:#007aff;text-decoration:none}a:hover{color:#0065ea;text-decoration:underline}button,i,img,input{vertical-align:middle}.tc{text-align:center}.auto{margin:0 auto}.mb20{margin-bottom:20px}.fl{float:left;display:inline}.oh{overflow:hidden}.fr{float:right}.i1{display:inline-block;margin-right:10px;width:80px;height:80px;border:1px solid #007aff;-webkit-border-radius:50%;-moz-border-radius:50%;border-radius:50%}.i1 img{margin-top:18px}.i2,.i2 span{position:absolute}.i2{left:123px;margin-top:-1px;bottom:-.5em;color:#dcdcdc;font:20px/1em Arial,Helvetica,sans-serif}.i2 span{color:#FFF;left:0;top:2px}.hd{font-weight:400;padding:20px 0;width:568px;margin-top:10%;border-bottom:1px solid #dcdcdc;position:relative}.bd{width:370px}.int1{border:1px solid #DDD;line-height:20px;padding:5px 10px;width:8em}.int1:focus{border-color:#007aff}.btn1{cursor:pointer;display:block;width:100%;line-height:20px;padding:5px 0;background-color:#007aff;color:#FFF;border:none 0}.btn1:hover{background-color:#0065ea}.p2_s1 img{margin:0 20px}.p2_s2{padding-top:5px}.p3{font-size:12px;color:#737373;margin-top:30px}</style>
- </head>
- <body>
- <h1 class="hd auto tc mb20"><i class="i1"><img src="https://pic1.zhimg.com/80/v2-dfeb5bdc6c835bb98eef84d99a293cdf_720w.jpg" width="39" height="48" src="22"></i>本站开启了密码保护<i class="i2">◆<span>◆</span></i></h1>
- <form id="captcha_form" class="bd auto" action="http://bbs.lxh5068.com/10169.html" method="post">
- <p class="mb20"><?php echo $p; ?></p>
- <p class="mb20 oh">
- <span class="fl p2_s1">
- <input type="password" name="pwd" placeholder="请输入密码" class="int1" autocomplete="off">
- </span></p>
- <input type="submit" value="提交" class="btn1"></input>
- </form>
- </body></html>
- <?php
- } ?>
复制代码
|