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




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 "点击返回";
}

?>

在这里输入登陆的信息:





Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.