我为两个管理员用户创建了一个表,我授予他们完全访问权限。会话不能在php中工作
session_start();
$query="select * from tbl_user where username='$username' and password='$password'";
$result=mysql_query($query);
$count=mysql_num_rows($result);
if($count>0)
{
$row=mysql_fetch_row($result);
if($row[0]=='1')
{
$_SESSION['admin']='admin';
}
else
{
$_SESSION['admin']='user';
}
header("Location:http://localhost/test/sample.php");
}
在这种sample.php
,我给这样的访问:
<td>
<?php
if($_SESSION['admin']=='admin')
{
?>
<a href='Subscribers.php'> Subscribers</a>
<?php
}
?>
</td>
<td>
<a href='CreateRelease.php'> Releases</a>
</td>
在sample.php
,我写了session_start
,但是,我可以与任何用户登录。只会显示Releases
选项。
有什么建议吗?
你的两个代码是否是同一个文件? –
@GlaciesofPacis:没有iam使用不同的文件 – VSK
tb_user的第一列是什么? – xdazz