Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/12/2011, 09:37
chumy_
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
seleccionar pagina dependiendo del usuario registrado

Estimados, tengo hoy el siguiente caso:

Tengo una pagina, la cual toma el nombre de usuario y la contraseña desde una base de datos, y da acceso a una pagina x. Con esto no hay dramas, todo ok, pero necesito que el codigo discrimine segun el atriburo que tenga cada usuario (administrador, tecnico o cliente) segun el campo de la base de datos, ya que actualmente me los envia todos a la misma pagina.

Código PHP:
<?php require_once('Connections/localhost.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$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_localhost$localhost);
$query_usuarios "SELECT * FROM usuarios";
$usuarios mysql_query($query_usuarios$localhost) or die(mysql_error());
$row_usuarios mysql_fetch_assoc($usuarios);
$totalRows_usuarios mysql_num_rows($usuarios);
?>
<?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['user'])) {
  
$loginUsername=$_POST['user'];
  
$password=$_POST['pass'];
  
$MM_fldUserAuthorization "atri";
  
$MM_redirectLoginSuccess "base_plataforma.php";
  
$MM_redirectLoginFailed "error.php";
  
$MM_redirecttoReferrer false;
  
mysql_select_db($database_localhost$localhost);
      
  
$LoginRS__query=sprintf("SELECT usuario, pass, atri FROM usuarios WHERE usuario=%s AND pass=%s",
  
GetSQLValueString($loginUsername"text"), GetSQLValueString($password"text")); 
   
  
$LoginRS mysql_query($LoginRS__query$localhost) or die(mysql_error());
  
$loginFoundUser mysql_num_rows($LoginRS);
  if (
$loginFoundUser) {
    
    
$loginStrGroup  mysql_result($LoginRS,0,'atri');
    
    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 );
  }
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es" dir="ltr">
<head>
<LINK REL="Shortcut Icon" HREF="icono.ico">
    <title>Plataforma</title>

    <!-- Contents -->
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Language" content="es" />
    <meta http-equiv="last-modified" content="04/04/2011 12:40:32" />
    <meta http-equiv="Content-Type-Script" content="text/javascript" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />
    <!-- imCustomHead -->
    <meta http-equiv="Expires" content="0" />
    <meta name="Resource-Type" content="document" />
    <meta name="Distribution" content="global" />
    <meta name="Robots" content="index, follow" />
    <meta name="Revisit-After" content="21 days" />
    <meta name="Rating" content="general" />
    <!-- Others -->
    <meta name="Generator" content="Incomedia WebSite X5 Evolution Evolution 8.0.9 - www.websitex5.com" />
    <meta http-equiv="ImageToolbar" content="False" />
    <meta name="MSSmartTagsPreventParsing" content="True" />
    
    <!-- Parent -->
    <link rel="sitemap" href="imsitemap.html" title="Mapa general del sitio" />
    <!-- Res -->
    <script type="text/javascript" src="res/x5engine.js"></script>
    <link rel="stylesheet" type="text/css" href="res/styles.css" media="screen, print" />
    <link rel="stylesheet" type="text/css" href="res/template.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="res/print.css" media="print" />
    <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="res/iebehavior.css" media="screen" /><![endif]-->
    <link rel="stylesheet" type="text/css" href="res/p003.css" media="screen, print" />
    <link rel="stylesheet" type="text/css" href="res/handheld.css" media="handheld" />
    <link rel="alternate stylesheet" title="Alto contraste - Accesibilidad" type="text/css" href="res/accessibility.css" media="screen" />

<style type="text/css">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}
</style>
</head>
<body link="#FFFFFF">
<div id="imSite">
  <table width="964" border="0">
    <tr>
      <td><img src="imagenes/logoOPT.jpg" alt="" width="200" height="85" /></td>
    <td align="right"><p><img src="imagenes/direcciones.jpg" alt="" width="250" height="106" /></p></td>
    </tr>
  </table>
  <div class="imInvisible">
  <hr />
<a href="#imGoToCont" title="Saltar el menú principal">Ir al Contenido</a>
</div>
<div id="imBody">
    <div>

<!-- Menu START -->
<a name="imGoToMenu"></a><p class="imInvisible">Menú Principal:</p>
<div id="imMnMn">
<ul>
    <li><a class="imMnItm_1" href="index.php" title=""><span class="imHidden">Presentación</span></a></li>
    <li><a class="imMnItm_2" href="noticias.html" title=""><span class="imHidden">Noticias</span></a></li>
    <li><a class="imMnItm_3" href="plataforma.php" title=""><span class="imHidden">Plataforma</span></a></li>
    <li><a class="imMnItm_5" href="contacto.html" title=""><span class="imHidden">Contacto</span></a></li>
</ul>
</div>
<!-- Menu END -->

    </div>
<hr class="imInvisible" />
<a name="imGoToCont"></a>
    <div id="imContent">

<!-- Page START -->
<h2>Plataforma</h2>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div id="imPage">
  <form id="form1" method="POST" action="<?php echo $loginFormAction?>">
    <p>&nbsp;</p>
    <table width="903" border="0">
      <tr>
        <td width="409" align="right">Usuario: </td>
        <td width="484"><label for="user2"></label>
          <input type="text" name="user" id="user2" /></td>
      </tr>
    </table>
<p>&nbsp;</p>
<p>
  <label for="user"></label>
  </p>
    <table width="904" border="0">
      <tr>
        <td width="409" align="right">Cotrase&ntilde;a</td>
        <td width="485"><label for="pass"></label>
          <input type="password" name="pass" id="pass" /></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    <label for="pass"></label>
<table width="903" border="0">
  <tr>
    <td width="409" align="right"><input type="submit" name="ingreso" id="ingreso" value="Ingresar" /></td>
    <td width="71" align="center">&nbsp;</td>
    <td width="409" align="left"><input type="reset" name="restablece" id="restablece" value="Borrar datos" /></td>
  </tr>
</table>
  </form>
</div>
<p id="imFooterSiteMap"><a href="index.php" title="">Presentación</a> | <a href="noticias.html" title="">Noticias</a> | <a href="plataforma.html" title="">Plataforma</a>| <a href="contacto.html" title="">Contacto</a> | <a href="imsitemap.html" title="Mapa general del sitio">Mapa del Sitio</a></p>

    </div>
</div>
</div>
<div class="imInvisible">
<hr />
<a href="#imGoToCont" title="Leer esta página de nuevo">Regresar al contenido</a> | <a href="#imGoToMenu" title="Leer este sitio de nuevo">Regresar al menú principal</a>
</div>


<div id="imShowBoxBG" style="display: none;" onClick="imShowBoxHide()"></div>
<div id="imShowBoxContainer" style="display: none;" onClick="imShowBoxHide()"><div id="imShowBox" style="height: 200px; width: 200px;"></div></div>
<div id="imBGSound"></div>
<div id="imToolTip"><script type="text/javascript">var imt = new IMTip;</script></div>
<script type="text/javascript">imPreloadImages('res/immnu_01b.gif,res/immnu_02b.gif,res/immnu_03b.gif,res/immnu_04b.gif,res/immnu_05b.gif')</script>
</body>
</html>
<?php
mysql_free_result
($usuarios);
?>