Pregunta: Como puedo hacer para que el usuario despues de logeado vaya automaticamente a la seccion que le corresponde segun su nivel?.
Esta es la tabla:
ID int(10) UNSIGNED No auto_increment
usuario varchar(45) latin1_swedish_ci No
password varchar(45) latin1_swedish_ci No
nombre varchar(45) latin1_swedish_ci No
apellido varchar(45) latin1_swedish_ci No
email varchar(45) latin1_swedish_ci No
nivel
y este el codigo en el dreamweaver:
Código PHP:
<?php require_once('../Connections/conex.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conex, $conex);
$query_loginadmin = "SELECT * FROM administradores";
$loginadmin = mysql_query($query_loginadmin, $conex) or die(mysql_error());
$row_loginadmin = mysql_fetch_assoc($loginadmin);
$totalRows_loginadmin = mysql_num_rows($loginadmin);
?><?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['usuario'])) {
$loginUsername=$_POST['usuario'];
$password=md5($_POST['password']);
$MM_fldUserAuthorization = "nivel";
$MM_redirectLoginSuccess = "seccion1.php";
$MM_redirectLoginFailed = "error.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_conex, $conex);
$LoginRS__query=sprintf("SELECT usuario, password, nivel FROM administradores WHERE usuario=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $conex) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'nivel');
//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 );
}
}
?>
<html>
<head>
<title>.:: Andinasoft- Colombia ::.</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META lang=es content="Andinasoft, software educativo, software para municipios,software empresarial,venta de equipos" name=Keywords>
<META content="Andinasoft Colombia." name=Description>
<META content=worldwide name=coverage>
<META content=all name=robots>
<META content=general name=rating>
<META content="1 days" name=revisit-after>
<meta name="distribution" content="local">
</script>
<script language="JavaScript1.2">
<!--
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->
</script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects"></script>
<script type="text/javascript" src="js/lightbox.js"></script>
<link href="estilo.css" rel="stylesheet" type="text/css">
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<link href="../estilo.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.Estilo1 {font-size: 16pt}
.Estilo2 {font-weight: bold}
-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="837" height="462" border="0" align="center" cellpadding="0" cellspacing="0" id="principal">
<tr>
<td width="2" height="462" class="leftshadow"></td>
<td width="831" height="462" valign="top" class="leftbox"><p align="center"> </p>
<p align="center"><span class="titulos Estilo2 Estilo1">PANEL DE ACCESO</span></p>
<p align="center"> </p>
<p align="center"> </p>
<form name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="49%" align="center">
<tr>
<th width="28%" scope="row"><img src="imagcpan/Login.jpg" alt="Login" width="80" height="80"></th>
<th width="28%" scope="row"><p> </p>
<div align="right">Usuario:</div></th>
<th width="72%" scope="row"><p>
</p>
<p>
<input name="usuario" type="text" id="usuario" size="45">
</p></th>
</tr>
<tr>
<th scope="row"> </th>
<th scope="row"><div align="right">Contraseña:</div></th>
<th scope="row"><input name="password" type="password" id="password" size="45"></th>
</tr>
</table>
<p>
<label>
<div align="center">
<input type="submit" name="button" id="button" value="Enviar">
</div>
</label>
</p>
</form>
<p> </p>
<p align="center"><a href="../index.php"><strong>IR A PAGINA PRINCIPAL/HOME</strong></a></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"> </p></td>
<td width="4" align="center" valign="top" class="watermark"> </td>
</tr>
</table>
</body>
</html>
<?php
mysql_free_result($loginadmin);
?>
Gracias a todos.