php网页密码登录代码

两天
两天
管理员
739
文章
0
粉丝
资源分享2267,0076字数 327阅读1分5秒阅读模式

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

  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. }
  35. </style>
  36. <![endif]-->
  37. <style type="text/css">
  38. <!--
  39. body{
  40. background:none;
  41. }
  42. .passport{
  43. border:1px solid red;
  44. background-color:#FFFFCC;
  45. width:400px;
  46. height:100px;
  47. position:absolute;
  48. left:49.9%;
  49. top:49.9%;
  50. margin-left:-200px;
  51. margin-top:-55px;
  52. font-size:14px;
  53. text-align:center;
  54. line-height:30px;
  55. color:#746A6A;
  56. }
  57. -->
  58. </style>
  59. <div class="passport">
  60. <div style="padding-top:20px;">
  61. <form action="?yes" method="post" style="margin:0px;">输入查看密码
  62. <input type="password" name="pwd" /> <input type="submit" value="查看" />
  63. </form>
  64. <?php echo $p; ?>
  65. </div>
  66. </div>
  67. <?php
  68. } ?>
  69. </body>
  70. </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:
                        确定

                        拖动滑块以完成验证
                        加载失败