<?
$pt_user_name=$_COOKIE['pt_user_name'];
if ($pt_user_name==''){
echo 'document.writeln("欢迎您的到来^0^ <a href=\"/User/Regters.aspx\">还没注册?</a>┊<a href=\"/User/ForgetPass.aspx\">忘记密码!</a> 帐号 <input name=\"username\" id=\"username\" size=\"10\" type=\"text\" class=\"inputout\" /> 密码 <input name=\"password\" id=\"password\" type=\"password\" size=\"10\" class=\"inputout\" /> <select name=\"CookieTime\" hidefocus ><option value=\"1\" selected=\"true\">保存一天</option><option value=\"30\">保存一月</option><option value=\"365\">保存一年</option></select> <input name=\"UserLogin\" type=\"submit\" value=\"会员登陆\" style=\"padding-top:2px;margin-top:2px;\">");';
}else{
$pt_user_data=$_SERVER['DOCUMENT_ROOT'].'/user/data/'.$pt_user_name.'.pt';
if(file_exists($pt_user_data)){ include_once $pt_user_data;}
echo 'document.writeln("欢迎 <font color=red><b>'.$busername.'</b></font> 回来^0^ <a href=\"/User/index.aspx\">个人书屋</a> ┊ <a href=\"/User/User_Booklist.aspx\">藏书架</a> ┊ <a href=\"/User/edit.aspx\">修改资料</a> ┊ <a href=\"/User/logout.aspx\">退出</a>");';
}
?>这个是我的登录代码
在页面中用js调用 调用代码是<script src="http://localhost/templets/menulogin.php"></script>
进行验证的代码是if ($username==$login_check_username && $userpass==md5($login_check_userpass)){
setcookie("pt_user_name",$username,$time,"/");
echo "<script>location.href='$comeurl';</script>";exit;
}
我在a页面登陆后,经过b判断,然后重新返回a页面,但是显示还是未登录,不过刷新一下就是登陆状态了
退出也是
这个是什么原因呢?
返回的是来路url
兄弟我看你先把php的基础先学好吧~~
你直接在URL里访问http://localhost/templets/menulogin.php呢