php网页密码登录代码

两天 资源分享2239K6字数 1365阅读4分33秒阅读模式

就是一段小代码段,新手可参考参考。

<?php
$password = "yige.org"; // 这里是密码
$p = "";
if(isset($_COOKIE["isview"]) and $_COOKIE["isview"] == $password){
    $isview = true;
}else{
    if(isset($_POST["pwd"])){
        if($_POST["pwd"] == $password){
            setcookie("isview",$_POST["pwd"],time()+3600*3);
            $isview = true;
        }else{
            $p = (empty($_POST["pwd"])) ? "需要密码才能查看,请输入密码。" : "密码不正确,请重新输入。";
        }
    }else{
        $isview = false;
        $p = "请输入密码查看,获取密码可联系我。";
    }
}
if($isview){ ?> 
这里是密码成功后显示的地方 
<?php }else{ ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<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 6]> 
<style type="text/css"> 
.z3_ie_fix{ 
float:left; 
} 
</style> 
<![endif]--> 
<style type="text/css"> 
<!-- 
body{ 
background:none; 
} 
.passport{ 
border:1px solid red; 
background-color:#FFFFCC; 
width:400px; 
height:100px; 
position:absolute; 
left:49.9%; 
top:49.9%; 
margin-left:-200px; 
margin-top:-55px; 
font-size:14px; 
text-align:center; 
line-height:30px; 
color:#746A6A; 
} 
--> 
</style> 
<div class="passport"> 
<div style="padding-top:20px;"> 
<form action="?yes" method="post" style="margin:0px;">输入查看密码 
<input type="password" name="pwd" /> <input type="submit" value="查看" /> 
</form> 
<?php echo $p; ?> 
</div> 
</div> 
<?php
} ?> 
</body> 
</html>
文章源自两天的博客-https://2days.org/2539.html文章源自两天的博客-https://2days.org/2539.html

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
312379857
←QQ扫一扫添加QQ好友
版权声明:本站原创文章转载请注明文章出处及链接,谢谢合作!
广告也精彩
 最后更新:2023-11-25
  • PHP
  • 代码
  • 网页
  • 密码登录
评论  22  访客  13  作者  9
    • 小清新头像吧
      小清新头像吧 3

      这个好像可以干点什么。。

      • 阿塔历斯
        阿塔历斯 2

        嗯,挺好呢,不过一般这个过程就让JS代劳吧,嘻嘻

        • 临沭人
          临沭人 2

          很实用,这个要收藏。

            • 两天
              两天

              @ 临沭人 comment” /> 也许某些时候能用到

            • 游戏赚吧丶
              游戏赚吧丶 1

              http://www.x173.com/?74 注册送1元,每天签到奖励0.5元,2元可以提现.邀请一个好友获得0.5元<。没注册的注册吧.各大站长最好也推一下,近期非常火 comment” />

              • 如初见
                如初见 1

                可是我是菜鸟,

                • Pablo Alboran
                  Pablo Alboran 0

                  实用!想当年为了这个急了半天!

                  • maillot radioshack
                    maillot radioshack 2

                    小白菜飘过~

                    • 微历史
                      微历史 3

                      看了博主的简历,编程是业余爱好?

                      • 内涵图
                        内涵图 1

                        内容不错

                        • Soar、毅
                          Soar、毅 1

                          给你32个赞~

                        匿名

                        发表评论

                        匿名网友
                        :?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
                        确定

                        拖动滑块以完成验证