login.html<html><head> <title>用戶登錄</title> <meta charset="utf-8"></head><body><title>請輸入。。。</title><form action="log.php?action=login" method="post">用戶名:<input type="text" name="username"><br>密碼:<input type="password" name="password" ><br><input type="submit" value="登陸"><input type="reset" value="清空"></form></body></html>log.php<?phpfunction clearCookies(){setcookie('username','',time()-3600);setcookie('username','',time()-3600);}if ($_GET["action"]=="login") {? ?clearCookies();? ?if ($_POST["username"]=="admin")&&$_POST["password"]=="123456"){? ? ? setcookie('username',$_POST["username"],time()+60*60*24*7);? ? ? setcookie('password',$_POST["password"],time()+60*60*24*7);? ? ? header("Localtion:text.php");? ?}else{? ? ? die("輸入錯誤TAT,請重新輸入~");}}else if($_GET["action"]=="logout"){clearCookies();?}?>text.php<?php?if(!(isset($_COOKIE['isLogin'])&&$_COOKIE['isLogin']=='1')){? header("Location:log.php");exit;?}??><html><head> <title>我的主頁</title> <meta charset="utf-8"></head><body><?phpecho "Hi".$_COOKIE["username"];?>歡迎進入~<a href="log.php? action=logout">退出</a></body></html>
php登陸頁面,不知道哪里出了問題,怎么改,請教QWQ~~
Momo_____
2017-05-14 15:05:13