php网页密码登录代码

两天 2014年04月7日18:48:50资源分享2231,8086字数 1580阅读5分16秒阅读模式

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

  1. <?php
  2. $password = "yige.org"// 这里是密码
  3. $p = "";
  4. if(isset($_COOKIE["isview"]) and $_COOKIE["isview"] == $password){
  5.     $isview = true;
  6. }else{
  7.     if(isset($_POST["pwd"])){
  8.         if($_POST["pwd"] == $password){
  9.             setcookie("isview",$_POST["pwd"],time()+3600*3);
  10.             $isview = true;
  11.         }else{
  12.             $p = (empty($_POST["pwd"])) ? "需要密码才能查看,请输入密码。" : "密码不正确,请重新输入。";
  13.         }
  14.     }else{
  15.         $isview = false;
  16.         $p = "请输入密码查看,获取密码可联系我。";
  17.     }
  18. }
  19. if($isview){ ?> 
  20. 这里是密码成功后显示的地方 
  21. <?php }else{ ?> 
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23. <html xmlns=" http://www.w3.org/1999/xhtml">
  24. <head> 
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  26. <meta http-equiv="pragma" content="no-cache" /> 
  27. <meta http-equiv="cache-control" content="no-cache" /> 
  28. <meta http-equiv="expires" content="0" /> 
  29. <title>去网游</title> 
  30. <!--[if lt IE 6]> 
  31. <style type="text/css"
  32. .z3_ie_fix{ 
  33. float:left; 
  34. </style> 
  35. <![endif]--> 
  36. <style type="text/css"
  37. <!-- 
  38. body{ 
  39. background:none; 
  40. .passport{ 
  41. border:1px solid red; 
  42. background-color:#FFFFCC; 
  43. width:400px; 
  44. height:100px; 
  45. position:absolute; 
  46. left:49.9%; 
  47. top:49.9%; 
  48. margin-left:-200px; 
  49. margin-top:-55px; 
  50. font-size:14px; 
  51. text-align:center; 
  52. line-height:30px; 
  53. color:#746A6A; 
  54. --> 
  55. </style> 
  56. <div class="passport"
  57. <div style="padding-top:20px;"
  58. <form action="?yes" method="post" style="margin:0px;">输入查看密码 
  59. <input type="password" name="pwd" /> <input type="submit" value="查看" /> 
  60. </form> 
  61. <?php echo $p; ?> 
  62. </div> 
  63. </div> 
  64. <?php
  65. } ?> 
  66. </body> 
  67. </html>

相关文章
继续阅读
  • 我的QQ
  • 这是我的qq扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
两天
  • 本文由 发表于 2014年04月7日18:48:50
  • 转载请务必保留本文链接:https://2days.org/2539.html
评论  22  访客  13  作者  9
    • 小清新头像吧
      小清新头像吧 3

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

      • 阿塔历斯
        阿塔历斯 2

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

        • 临沭人
          临沭人 2

          很实用,这个要收藏。

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

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

            • 如初见
              如初见 1

              可是我是菜鸟,

              • Pablo Alboran
                Pablo Alboran 0

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

                • maillot radioshack
                  maillot radioshack 3

                  小白菜飘过~

                  • 微历史
                    微历史 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:

                      确定