找回密码
 注册账户
查看: 2470|回复: 2

Protect a PHP page 加密PHP页面

[复制链接]
admin 发表于 2008-1-3 02:45:25 | 显示全部楼层 |阅读模式
$pass = "YOUR PASSWORD HERE";
$user = "YOUR USERNAME HERE";

<?php
        session_start(); //initiates the sessions
        if      ($_POST[’submit’])//checks to make sure the login form has been submitted
        {
        $pass = "YOUR PASSWORD HERE";
        $user = "YOUR USERNAME HERE";
        if      ($_POST[‘pass’] == $pass && $_POST[‘user’] == $user)//checks if the password submitted by the user matches the password stored in the $pass variable
        {
        $_SESSION[‘access’]     = 1;//if login is successful create a session that can be authenticated
        header("Location: " . $_SERVER[‘PHP_SELF’]);//reload the page. The page will now not load the login form (see the first if condition)
        }
        else// if password is incorrect reload the login form
        {
        header("Location: " . $_SERVER[‘PHP_SELF’]);
        }
        }
        else if (!$_SESSION[‘access’])//if the "access" session is not accessible show the form (not logged in)
        {?>
        <form action="<?php echo $_SERVER[’PHP_SELF’]; ?>" method="post">
        <table align="center" cellpadding="3" cellspacing="3">
        <tr>
        <td bgcolor="#F7F7F7">Username:</td>
        <td bgcolor="#F7F7F7"> <input name="user" type="text" /></td>
        </tr>
        <tr>
        <td bgcolor="#F7F7F7">Password</td>
        <td bgcolor="#F7F7F7"><input name="pass" type="text" /></td>
        </tr>
        <tr>
        <td colspan="2" bgcolor="#F7F7F7"><div align="center">
        <input name="submit" type="submit" value="Login">
        </div></td>
        </tr>
        </table>
        </form>
        <?php
        exit;
        }
        ?>
hbthomes 发表于 2008-2-29 16:01:15 | 显示全部楼层

正需要推广呢.谢谢

正需要推广呢.谢谢
poeeop 发表于 2008-3-28 09:43:48 | 显示全部楼层
谢谢分享。。。。。。。。
您需要登录后才可以回帖 登录 | 注册账户

本版积分规则

存档|黑屋|手机|网络实验室 本站服务器由美国合租以及IDCLayer国际数据提供!!!

GMT+8, 2026-6-4 20:34 , Processed in 0.011430 second(s), 10 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表