php 存储权限登陆跳转到不同页面,大神帮帮忙啊!!!
用户数据库是这样的。limit为1代表是管理员,0为用户,怎么根据权限不同跳转到不同的页面上啊?我用的Dreamweaver服务器行为那里添加了用户登陆行为,产生了下面的...
用户数据库是这样的。
limit为1代表是管理员,0为用户,怎么根据权限不同跳转到不同的页面上啊?我用的Dreamweaver服务器行为那里添加了用户登陆行为,产生了下面的代码,那怎么修改啊?????求帮助!!!
<?php// *** Validate request to login to this site.if (!isset($_SESSION)) { session_start();}
$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];}
if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = "limit"; $MM_redirectLoginSuccess = "index2.php"; $MM_redirectLoginFailed = "login-fail.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_www, $www); $LoginRS__query=sprintf("SELECT username, password, limit FROM `s-user` WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $www) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'limit'); if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); }}?> 展开
limit为1代表是管理员,0为用户,怎么根据权限不同跳转到不同的页面上啊?我用的Dreamweaver服务器行为那里添加了用户登陆行为,产生了下面的代码,那怎么修改啊?????求帮助!!!
<?php// *** Validate request to login to this site.if (!isset($_SESSION)) { session_start();}
$loginFormAction = $_SERVER['PHP_SELF'];if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck'];}
if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = "limit"; $MM_redirectLoginSuccess = "index2.php"; $MM_redirectLoginFailed = "login-fail.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_www, $www); $LoginRS__query=sprintf("SELECT username, password, limit FROM `s-user` WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $www) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = mysql_result($LoginRS,0,'limit'); if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); }}?> 展开
展开全部
$loginFoundUser = mysql_num_rows($LoginRS); //这里是登陆
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'limit');//返回结果
这里加个判断,判断limit的值,如果为1,就跳转到index1,如果为0就跳转为index
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'limit');//返回结果
这里加个判断,判断limit的值,如果为1,就跳转到index1,如果为0就跳转为index
追问
能写一下代码么……我是一点儿都不回啊………………%>_<%
追答
if($loginStrGroup == 1){
header("Location: ". "URL" );
}else{
header("Location: ". "URL");
}
不知道对不对,我也不怎么会PHP,我这里也没法测试。你可以打印一下这个 $loginStrGroup 这个值是什么?我看他是返回指定一个字段的值,指定了limit这个字段。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "limit";
$MM_redirectLoginSuccess_user = "index1.php";
$MM_redirectLoginSuccess_admin = "index2.php";
$MM_redirectLoginFailed = "login-fail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_www, $www);
$LoginRS__query=sprintf("SELECT username, password, limit FROM `s-user` WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $www) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'limit');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
if($loginStrGroup == 1){
header("Location: " . $MM_redirectLoginSuccess_admin );
}else{
header("Location: " . $MM_redirectLoginSuccess_user );
}
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['password'];
$MM_fldUserAuthorization = "limit";
$MM_redirectLoginSuccess_user = "index1.php";
$MM_redirectLoginSuccess_admin = "index2.php";
$MM_redirectLoginFailed = "login-fail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_www, $www);
$LoginRS__query=sprintf("SELECT username, password, limit FROM `s-user` WHERE username=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $www) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'limit');
if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
if($loginStrGroup == 1){
header("Location: " . $MM_redirectLoginSuccess_admin );
}else{
header("Location: " . $MM_redirectLoginSuccess_user );
}
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
追答
表的字段 最好不要用sql 的关键字 如果使用了
这儿需要 用 `` 来表明是字段
所以 查询的地方要改成下面的
$loginStrGroup = mysql_result($LoginRS,0,'`limit`');
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询