PHP权限代码怎么写? 10
staff_right是表staff中的一个字段,存储权限等级,登陆判断页面如下,需要判断权限的页面怎么写判断?<?phpsession_start();include(...
staff_right是表staff中的一个字段,存储权限等级,
登陆判断页面如下,需要判断权限的页面怎么写判断?
<?php
session_start();
include("conn.php");
if (!$link) { die('Could not connect: ' . mysql_error()); }
else { mysql_select_db('a1217195241', $link) or die ('Can\'t use user : ' . mysql_error());
$sql = "select * from staff where staff_username='".$staff_username."' and staff_password='".$staff_password."'";
$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
if (mysql_num_rows($result) > 0)
{ mysql_close($link);
$_SESSION['staff_username'] = 'staff_username';
echo "<script type='text/javascript'>alert('系统提示:恭喜你!登陆系统成功!');</script>";
echo "<script type='text/javascript'>window.location.href='main.html'</script>";
} else
{
echo "<script type='text/javascript'>alert('系统提示:用户名或密码错误,请重新输入!');</script>";
echo "<script type='text/javascript'>window.location.href='login.php'</script>";
}
}
?> 展开
登陆判断页面如下,需要判断权限的页面怎么写判断?
<?php
session_start();
include("conn.php");
if (!$link) { die('Could not connect: ' . mysql_error()); }
else { mysql_select_db('a1217195241', $link) or die ('Can\'t use user : ' . mysql_error());
$sql = "select * from staff where staff_username='".$staff_username."' and staff_password='".$staff_password."'";
$result = mysql_query($sql) or die("Invalid query: " . mysql_error());
if (mysql_num_rows($result) > 0)
{ mysql_close($link);
$_SESSION['staff_username'] = 'staff_username';
echo "<script type='text/javascript'>alert('系统提示:恭喜你!登陆系统成功!');</script>";
echo "<script type='text/javascript'>window.location.href='main.html'</script>";
} else
{
echo "<script type='text/javascript'>alert('系统提示:用户名或密码错误,请重新输入!');</script>";
echo "<script type='text/javascript'>window.location.href='login.php'</script>";
}
}
?> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询