PHP登入登出系统

来源:互联网 发布:php乘法表for 编辑:程序博客网 时间:2024/06/11 05:03

------------------------------------~index.php-------------------------------------------

<html>

<head>
<title>欢迎访问yc综合系统</title>
</head>
<body>
<?php
    if(isset($_GET["debug"]))
        setcookie("login","",time()-3600);
    if(isset($_COOKIE['login'])) {
        echo "<a href='./index.php'>您已登录,单击此处跳转";
        exit();
    }else {
?>
<p>请登录</p>
<form name="input" action="./~index.php" method="post">
用户名: 
<input type="text" name="user" />
密码: 
<input type="password" name="password" />
<input type="submit" value="Submit" />
</form>
<?php
    }
    if(isset($_POST['user'])&&isset($_POST['password'])) {
        setcookie("login","1",time()+3600);   
        echo "<script language='javascript'>window.location.reload();</script>";
        exit();
    }
?>
</body>

</html>

----------------------------------------------------------------------------------------------------------