php页面怎么设置一个网页的访问密码

2025-04-29 04:13:41

1、密码对,就可以看到指定内容, 密码不对就进不去;首次打开和关闭浏览器重新打开 都需要输入密码才可以访问,具体代码如下:

php页面怎么设置一个网页的访问密码

2、$adminkey = "admin"; /*----颍骈城茇-------------请在上面修改登陆密码,默认密码是admin---------------- */ session_start(); if(@$_POST['password'] == $adminkey){ $_SESSION['login'] = md5($adminkey); } if($_SERVER['QUERY_STRING'] == "logout"){ $_SESSION['login'] = ""; header("location: " . $_SERVER['PHP_SELF']); exit(); } $html_login = <<<EOF <!DOCTYPE html> <html> <head> <title>PHP探针-登录</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style> div{text-align:center; margin:0 auto;} #loginform{width:350px;height:100px;background-color:#F8F8FF;box-shadow: 1px 1px 1px 1px #888888;} </style> </head> <body> <div id="loginform"> <div style="text-align:center; margin:30px auto 0px;"><form action="" method="post">&nbsp;独立查看密码&nbsp;<input type="password" name="password" style="width:120px; margin-top: 35px;"><input type="submit" value="登录" style="margin-left: 5px;"></form></div> </div> </body> </html>

php页面怎么设置一个网页的访问密码

3、另外,还可以在登陆进去后陆页面,添加一个“退出瞌蕞凿鸠登录”的按钮,把下面代码加到页面相应位置即可:<a href="?logout" style="col泠贾高框or: red;">退出登录</a>

4、方法2:

php页面怎么设置一个网页的访问密码

5、下面的代码可以跳转并添加修改密码的php

php页面怎么设置一个网页的访问密码

6、第一个效果

php页面怎么设置一个网页的访问密码
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢