Home > php教程 > php手册 > session的奇怪问题(已经搜索过,自己还解决不了)

session的奇怪问题(已经搜索过,自己还解决不了)

WBOY
Release: 2016-06-13 09:54:37
Original
1562 people have browsed it




session的奇怪问题(已经搜索过,自己还解决不了)

我的登陆主页面,就是判断是否登陆,直接输入地址饶过登陆窗口,第一次出现 你无权访问 ,session文件里出现admin|b:0; 刷新一次,出现 你已经登陆
Notice: Undefined index: name in d:usrwwwhtmldengluindex.php on line 5
111122223333
session文件里的那个文件又变成admin|b:1; admin的值为1了。奇怪呀!!!
这就是index.php的代码:

$admin=false;
if(isset($_SESSION['admin'])&&$_SESSION['admin']=true)
{ echo "你已经登陆";
echo $_SESSION['name'];
}
else
{$_SESSION['admin']=false;

die("你无权访问");
header("Location:login.htm");
}

?>

111122223333






在前面的验证中,如果用户名和密码正确,则让$_SESSION['admin'] = true;

这是 login.php代码:
$xm=$_POST['xingming'];
$ps=$_POST['password'];
$_SESSION['admin'] = false;
$link = mysql_connect('localhost','root','');
$db = mysql_select_db('hehetsg');
$result = mysql_query("select * from user where user = '$xm' and psw ='$ps'");
if ($row=mysql_fetch_array($result))
{ if ($row['psw']==$ps and $row['flag']==1)
{ $_SESSION['name']=$row['name'];
$_SESSION['admin'] = true;
echo "欢迎管理员进入!";
echo "管理界面";

}
else
{ echo "不是管理员。对不起!";
echo "点击返回";
}
}
else { echo "你的信息不全!";
echo "点击返回";
}

?>

在这里输入登陆的信息:





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template