同样的登录代码,ff中没有问题,ie就是不行。。
登录页面 : login.php
共有三个页面,想要打开其它两个页面,若未登录,都会先跳转到登录页面。
输入用户名眼密码正确后,保存到session中,这时可以自由浏览各个页面,不需要重复登录。
ff中没有问题,实现的跟预期一样,
ie中一直显示登录页面,session没有保存成功。希望phper能帮忙解答。谢谢
附完整的 login.php 的代码,如下:
<script language="javascript" >
function FrontPage_Form1_Validator(theForm)
{
if(theForm.admin_user.value=="")
{
alert("please input admin account:");
theForm.admin_user.focus();
return(false);
}
if(theForm.admin_pass.value=="")
{
alert("please input admin passport:");
theForm.admin_pass.focus();
return(false);
}
return(true);
}
</script>
<div id="submit">
<?php
if($_GET[out]){
unset($_SESSION['admin_user']);
unset($_SESSION['admin_pass']);
echo "<script language=\"javascript\">location.href='admin_login.php';</script>";
}
if(!isset($_SESSION['admin_user'])) //**** if ****
{
if(!$_POST['submit']){
echo "please login first!";
include 'login.htm';
}
else{
$admin_user=$_POST['admin_user'];
//echo $admin_user;
$admin_pass=$_POST['admin_pass'];
$rs=$db->execute("select admin_user,admin_pass from ".TABLE_PREFIX."gbconfig where admin_user='".$admin_user."'");
if($db->num_rows($rs)>=1){
$row=$db->fetch_array($rs);
$db->free_result($rs);
//echo "free_result run <br/>".$admin_pass."<br/>";
if($row['admin_pass']==$admin_pass){
$_SESSION['admin_user']=$admin_user;
$_SESSION['admin_pass']=$admin_pass;// save session
//echo "session save successful";
echo "login successful , please wait....<br/><a href=index.php>if the browser do not return to the home page ,please click here</a>";
if(isset($_SESSION['userurl'])){
$url=$_SESSION['userurl'];
//header("location:$url");
//location.href=$_SESSION['userurl'];
echo "<meta http-equiv=\"refresh\" content=\"2;url=$url\">";
}
else
echo "<meta http-equiv=\"refresh\" content=\"2;url=index.php\">";
//echo "<script language=\"javascript\">history.go(-1)</script>";
}
else{
echo "<script language=\"javascript\">alert('wrong password!');history.go(-1)</script>";
}
}
else{
echo "<script language=\"javascript\">alert('wrong account!');</script>";
echo "<meta http-equiv=\"refresh\" content=\"2;url=register.php?admin_user=$admin_user&admin_pass=$admin_pass\">";
}
}
}
else{ // **** else ****
?>
<div id="alertmsg">
<a href='?out=exit'>退出</a>
<?
echo "show list";
?>
</div><!--end div#alertmsg-->
<?php
}?>
</div><!--end div#main-->
<h2>管理登录页面</h2>
</body>
</html>
[解决办法]
我怎么没有看到 session_start();呢?
[解决办法]
可能是你js兼容性的问题