我爲兩個管理員用戶創建了一個表,我授予他們完全訪問權限。會話不能在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