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

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"> 独立查看密码 <input type="password" name="password" style="width:120px; margin-top: 35px;"><input type="submit" value="登录" style="margin-left: 5px;"></form></div> </div> </body></html>

3、另外,还可以在登陆进去后陆页面,添加一个“退出登录”的按钮,把下面代码加到页面相应位置即可:
<a href="?logout" style="color: red;">退出登录</a>
4、方法2:

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

6、第一个效果
