Foros del Web » Programando para Internet » PHP »

seleccionar pagina dependiendo del usuario registrado

Estas en el tema de seleccionar pagina dependiendo del usuario registrado en el foro de PHP en Foros del Web. revisare el codigo y y cuando lo tenga te lo subo haber si alguien mientras tanto puede ver el fallo...

  #31 (permalink)  
Antiguo 19/12/2011, 13:53
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

revisare el codigo y y cuando lo tenga te lo subo

haber si alguien mientras tanto puede ver el fallo

Última edición por webankenovi; 19/12/2011 a las 13:59
  #32 (permalink)  
Antiguo 19/12/2011, 14:20
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

haber prueba esto

Código PHP:
Ver original
  1. <?php
  2.  
  3. require_once('Connections/localhost.php');
  4.  
  5. if (!function_exists("GetSQLValueString")) {
  6. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  7. {
  8.   if (PHP_VERSION < 6) {
  9.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  10.   }
  11.  
  12.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  13.  
  14.   switch ($theType) {
  15.     case "text":
  16.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  17.       break;    
  18.     case "long":
  19.     case "int":
  20.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  21.       break;
  22.     case "double":
  23.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  24.       break;
  25.     case "date":
  26.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  27.       break;
  28.     case "defined":
  29.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  30.       break;
  31.   }
  32.   return $theValue;
  33. }
  34. }
  35.  
  36. mysql_select_db($database_localhost, $localhost);
  37. $query_usuarios = "SELECT * FROM usuarios";
  38. $usuarios = mysql_query($query_usuarios, $localhost) or die(mysql_error());
  39. $row_usuarios = mysql_fetch_assoc($usuarios);
  40. $totalRows_usuarios = mysql_num_rows($usuarios);
  41.  
  42. $loginFormAction = $_SERVER['PHP_SELF'];
  43. if (isset($_GET['accesscheck'])) {
  44.   $_SESSION['PrevUrl'] = $_GET['accesscheck'];
  45. }
  46.  
  47. if (isset($_POST['user'])) {
  48.   $loginUsername=$_POST['user'];
  49.   $password=$_POST['pass'];
  50.   $MM_fldUserAuthorization = "atri";
  51.   $MM_redirectLoginAdmin = "admins.php";        /*pagina de administradores*/
  52.   $MM_redirectLoginTecnico = "tecnicos.php";    /*pagina de tecnicos*/
  53.   $MM_redirectLoginClientes = "clientes.php";   /*pagina de clientes*/
  54.   $MM_redirectLoginFailed = "error.php";        /*pagina de error*/
  55.   $MM_redirecttoReferrer = false;
  56.   mysql_select_db($database_localhost, $localhost);
  57.      
  58.   $LoginRS__query=sprintf("SELECT usuario, pass, atri FROM usuarios WHERE usuario=%s AND pass=%s",
  59.   GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  60.    
  61.   $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
  62.   $loginFoundUser = mysql_num_rows($LoginRS);
  63.  
  64.   if ($loginFoundUser) {
  65.    
  66.     $loginStrGroup  = mysql_result($LoginRS,0,'atri');
  67.    
  68.     if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  69.     //declare two session variables and assign them
  70.     $_SESSION['MM_Username'] = $loginUsername;
  71.     $_SESSION['MM_UserGroup'] = $loginStrGroup;
  72.              
  73.     if (isset($_SESSION['PrevUrl']) && false) {
  74.       $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
  75.          
  76.     }else{
  77.        
  78.        
  79.         if($_SESSION['MM_UserGroup'] == 'administrador'){
  80.        
  81.         header("Location: ". $MM_redirectLoginAdmin );
  82.        
  83.         }elseif($_SESSION['MM_UserGroup'] == 'cliente'){
  84.        
  85.         header("Location: ". $MM_redirectLoginTecnico );
  86.        
  87.         }elseif($_SESSION['MM_UserGroup'] == 'tecnico'){
  88.        
  89.         header("Location: ". $MM_redirectLoginCliente );}
  90.        
  91.        
  92.     }
  93.  
  94.  
  95. } else {header("Location: ". $MM_redirectLoginFailed );}
  96.  
  97. }
  98. ?>
  99. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es" dir="ltr">
  100. <head>
  101. <LINK REL="Shortcut Icon" HREF="icono.ico">
  102.     <title>Plataforma</title>
  103.  
  104.     <!-- Contents -->
  105.     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  106. <meta http-equiv="Content-Language" content="es" />
  107.     <meta http-equiv="last-modified" content="04/04/2011 12:40:32" />
  108.     <meta http-equiv="Content-Type-Script" content="text/javascript" />
  109.     <meta name="description" content="" />
  110.     <meta name="keywords" content="" />
  111.     <!-- imCustomHead -->
  112.     <meta http-equiv="Expires" content="0" />
  113.     <meta name="Resource-Type" content="document" />
  114.     <meta name="Distribution" content="global" />
  115.     <meta name="Robots" content="index, follow" />
  116.     <meta name="Revisit-After" content="21 days" />
  117.     <meta name="Rating" content="general" />
  118.     <!-- Others -->
  119.     <meta name="Generator" content="Incomedia WebSite X5 Evolution Evolution 8.0.9 - www.websitex5.com" />
  120.     <meta http-equiv="ImageToolbar" content="False" />
  121.     <meta name="MSSmartTagsPreventParsing" content="True" />
  122.    
  123.     <!-- Parent -->
  124.     <link rel="sitemap" href="imsitemap.html" title="Mapa general del sitio" />
  125.     <!-- Res -->
  126.     <script type="text/javascript" src="res/x5engine.js"></script>
  127.     <link rel="stylesheet" type="text/css" href="res/styles.css" media="screen, print" />
  128.     <link rel="stylesheet" type="text/css" href="res/template.css" media="screen" />
  129.     <link rel="stylesheet" type="text/css" href="res/print.css" media="print" />
  130.     <!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="res/iebehavior.css" media="screen" /><![endif]-->
  131.     <link rel="stylesheet" type="text/css" href="res/p003.css" media="screen, print" />
  132.     <link rel="stylesheet" type="text/css" href="res/handheld.css" media="handheld" />
  133.     <link rel="alternate stylesheet" title="Alto contraste - Accesibilidad" type="text/css" href="res/accessibility.css" media="screen" />
  134.  
  135. <style type="text/css">
  136. body,td,th {
  137.     font-family: Arial, Helvetica, sans-serif;
  138.     font-size: 12px;
  139. }
  140. </style>
  141. </head>
  142. <body link="#FFFFFF">
  143. <div id="imSite">
  144.   <table width="964" border="0">
  145.     <tr>
  146.       <td><img src="imagenes/logoOPT.jpg" alt="" width="200" height="85" /></td>
  147.     <td align="right"><p><img src="imagenes/direcciones.jpg" alt="" width="250" height="106" /></p></td>
  148.     </tr>
  149.   </table>
  150.   <div class="imInvisible">
  151.   <hr />
  152. <a href="#imGoToCont" title="Saltar el menú principal">Ir al Contenido</a>
  153. </div>
  154. <div id="imBody">
  155.     <div>
  156.  
  157. <!-- Menu START -->
  158. <a name="imGoToMenu"></a><p class="imInvisible">Menú Principal:</p>
  159. <div id="imMnMn">
  160. <ul>
  161.     <li><a class="imMnItm_1" href="index.php" title=""><span class="imHidden">Presentación</span></a></li>
  162.     <li><a class="imMnItm_2" href="noticias.html" title=""><span class="imHidden">Noticias</span></a></li>
  163.     <li><a class="imMnItm_3" href="plataforma.php" title=""><span class="imHidden">Plataforma</span></a></li>
  164.     <li><a class="imMnItm_5" href="contacto.html" title=""><span class="imHidden">Contacto</span></a></li>
  165. </ul>
  166. </div>
  167. <!-- Menu END -->
  168.  
  169.     </div>
  170. <hr class="imInvisible" />
  171. <a name="imGoToCont"></a>
  172.     <div id="imContent">
  173.  
  174. <!-- Page START -->
  175. <h2>Plataforma</h2>
  176. <p>&nbsp;</p>
  177. <p>&nbsp;</p>
  178. <p>&nbsp;</p>
  179. <div id="imPage">
  180.   <form id="form1" method="POST" action="<?php echo $loginFormAction; ?>">
  181.     <p>&nbsp;</p>
  182.     <table width="903" border="0">
  183.       <tr>
  184.         <td width="409" align="right">Usuario: </td>
  185.         <td width="484"><label for="user2"></label>
  186.           <input type="text" name="user" id="user2" /></td>
  187.       </tr>
  188.     </table>
  189. <p>&nbsp;</p>
  190. <p>
  191.   <label for="user"></label>
  192.   </p>
  193.     <table width="904" border="0">
  194.       <tr>
  195.         <td width="409" align="right">Cotrase&ntilde;a</td>
  196.         <td width="485"><label for="pass"></label>
  197.           <input type="password" name="pass" id="pass" /></td>
  198.       </tr>
  199.     </table>
  200.     <p>&nbsp;</p>
  201.     <label for="pass"></label>
  202. <table width="903" border="0">
  203.   <tr>
  204.     <td width="409" align="right"><input type="submit" name="ingreso" id="ingreso" value="Ingresar" /></td>
  205.     <td width="71" align="center">&nbsp;</td>
  206.     <td width="409" align="left"><input type="reset" name="restablece" id="restablece" value="Borrar datos" /></td>
  207.   </tr>
  208. </table>
  209.   </form>
  210. </div>
  211. <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>
  212.  
  213.     </div>
  214. </div>
  215. </div>
  216. <div class="imInvisible">
  217. <hr />
  218. <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>
  219. </div>
  220.  
  221.  
  222. <div id="imShowBoxBG" style="display: none;" onClick="imShowBoxHide()"></div>
  223. <div id="imShowBoxContainer" style="display: none;" onClick="imShowBoxHide()"><div id="imShowBox" style="height: 200px; width: 200px;"></div></div>
  224. <div id="imBGSound"></div>
  225. <div id="imToolTip"><script type="text/javascript">var imt = new IMTip;</script></div>
  226. <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>
  227. </body>
  228. </html>
  229. <?php
  230. mysql_free_result($usuarios);
  231. ?>

En algun lado del body pon <?php echo $loginStrGroup; ?> esto para saber que valor le da por que el fallo puede venir de aqui esto es solo para verificacion.
  #33 (permalink)  
Antiguo 19/12/2011, 14:43
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: seleccionar pagina dependiendo del usuario registrado

ya.... a ver... en IE me devulve al index.php y tanto en firefox como en chrome no me envia a ninguna pagina, se devuelve a plataforma.php al entrar como un usuario tecnico, y cuando entro como cliente entra a la pagina que tengo determinada para los tecnicos O.o

al entrar como tecnico, con el php que me diste, aparece la leyenda tecnico....
  #34 (permalink)  
Antiguo 20/12/2011, 10:38
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

Código PHP:
Ver original
  1. <?php
  2.  
  3. require_once('Connections/localhost.php');
  4.  
  5. if (!function_exists("GetSQLValueString")) {
  6. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  7. {
  8.   if (PHP_VERSION < 6) {
  9.     $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  10.   }
  11.  
  12.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  13.  
  14.   switch ($theType) {
  15.     case "text":
  16.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  17.       break;    
  18.     case "long":
  19.     case "int":
  20.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  21.       break;
  22.     case "double":
  23.       $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  24.       break;
  25.     case "date":
  26.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  27.       break;
  28.     case "defined":
  29.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  30.       break;
  31.   }
  32.   return $theValue;
  33. }
  34. }
  35.  
  36. mysql_select_db($database_localhost, $localhost);
  37. $query_usuarios = "SELECT * FROM usuarios";
  38. $usuarios = mysql_query($query_usuarios, $localhost) or die(mysql_error());
  39. $row_usuarios = mysql_fetch_assoc($usuarios);
  40. $totalRows_usuarios = mysql_num_rows($usuarios);
  41.  
  42. $loginFormAction = $_SERVER['PHP_SELF'];
  43.  
  44. if (isset($_POST['user'])) {
  45.   $loginUsername=$_POST['user'];
  46.   $password=$_POST['pass'];
  47.   $MM_fldUserAuthorization = "atri";
  48.   $MM_redirectLoginAdmin = "admins.php";        /*pagina de administradores*/
  49.   $MM_redirectLoginTecnico = "tecnicos.php";    /*pagina de tecnicos*/
  50.   $MM_redirectLoginClientes = "clientes.php";   /*pagina de clientes*/
  51.   $MM_redirectLoginFailed = "error.php";        /*pagina de error*/
  52.   $MM_redirecttoReferrer = false;
  53.   mysql_select_db($database_localhost, $localhost);
  54.      
  55.   $LoginRS__query=sprintf("SELECT usuario, pass, atri FROM usuarios WHERE usuario=%s AND pass=%s",
  56.   GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  57.    
  58.   $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
  59.   $loginFoundUser = mysql_num_rows($LoginRS);
  60.  
  61.   if ($loginFoundUser) {
  62.    
  63.     $loginStrGroup  = mysql_fetch_array($LoginRS);
  64.    
  65.     if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  66.     //declare two session variables and assign them
  67.     $_SESSION['MM_Username'] = $loginUsername;
  68.     $_SESSION['MM_UserGroup'] = $loginStrGroup['atri'];
  69.            
  70.        
  71.         if($_SESSION['MM_UserGroup'] == 'administrador'){
  72.        
  73.         header("Location: ". $MM_redirectLoginAdmin );
  74.        
  75.         }elseif($_SESSION['MM_UserGroup'] == 'cliente'){
  76.        
  77.         header("Location: ". $MM_redirectLoginTecnico );
  78.        
  79.         }elseif($_SESSION['MM_UserGroup'] == 'tecnico'){
  80.        
  81.         header("Location: ". $MM_redirectLoginCliente );}
  82.        
  83.        
  84.    
  85.  
  86.  
  87. } else {header("Location: ". $MM_redirectLoginFailed );}
  88.  
  89. }
  90. ?>

prueba asi y me cuentas
  #35 (permalink)  
Antiguo 20/12/2011, 11:41
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: seleccionar pagina dependiendo del usuario registrado

ahora dice Array
  #36 (permalink)  
Antiguo 20/12/2011, 14:18
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

como que array? dondete sale? te redirige a algun lado ? especifica un poco para poder comprender el problema
  #37 (permalink)  
Antiguo 20/12/2011, 15:08
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: seleccionar pagina dependiendo del usuario registrado

en vez de aparecer "tecnico" aparece "array" con la funcion "<?php echo $loginStrGroup; ?>" y no me redirige a ningun lado, se queda en "plataforma.php"
  #38 (permalink)  
Antiguo 20/12/2011, 15:52
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

Código PHP:
Ver original
  1. <?php
  2.     session_start();
  3.      
  4.     require_once('Connections/localhost.php');
  5.      
  6.     if (!function_exists("GetSQLValueString")) {
  7.     function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
  8.     {
  9.       if (PHP_VERSION < 6) {
  10.         $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  11.       }
  12.      
  13.       $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  14.      
  15.       switch ($theType) {
  16.         case "text":
  17.           $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  18.           break;    
  19.         case "long":
  20.         case "int":
  21.           $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  22.           break;
  23.         case "double":
  24.           $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
  25.           break;
  26.         case "date":
  27.           $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  28.           break;
  29.         case "defined":
  30.           $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  31.           break;
  32.       }
  33.       return $theValue;
  34.     }
  35.     }
  36.      
  37.     mysql_select_db($database_localhost, $localhost);
  38.     $query_usuarios = "SELECT * FROM usuarios";
  39.     $usuarios = mysql_query($query_usuarios, $localhost) or die(mysql_error());
  40.     $row_usuarios = mysql_fetch_assoc($usuarios);
  41.     $totalRows_usuarios = mysql_num_rows($usuarios);
  42.      
  43.     $loginFormAction = $_SERVER['PHP_SELF'];
  44.      
  45.     if (isset($_POST['user'])) {
  46.       $loginUsername=$_POST['user'];
  47.       $password=$_POST['pass'];
  48.       $MM_fldUserAuthorization = "atri";
  49.       $MM_redirectLoginAdmin = "admins.php";        /*pagina de administradores*/
  50.       $MM_redirectLoginTecnico = "tecnicos.php";    /*pagina de tecnicos*/
  51.       $MM_redirectLoginClientes = "clientes.php";   /*pagina de clientes*/
  52.       $MM_redirectLoginFailed = "error.php";        /*pagina de error*/
  53.       $MM_redirecttoReferrer = false;
  54.       mysql_select_db($database_localhost, $localhost);
  55.          
  56.       $LoginRS__query=sprintf("SELECT usuario, pass, atri FROM usuarios WHERE usuario=%s AND pass=%s",
  57.       GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  58.        
  59.       $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error());
  60.      $loginStrGroup  = mysql_fetch_array($LoginRS);
  61.  
  62.       if ($loginStrGroup  ) {
  63.        
  64.        
  65.        
  66.         if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
  67.         //declare two session variables and assign them
  68.         $_SESSION['MM_Username'] = $loginUsername;
  69.         $_SESSION['MM_UserGroup'] = $loginStrGroup['atri'];
  70.                
  71.            
  72.             if($_SESSION['MM_UserGroup'] == 'administrador'){
  73.            
  74.             header("Location: ". $MM_redirectLoginAdmin );
  75.            
  76.             }elseif($_SESSION['MM_UserGroup'] == 'cliente'){
  77.            
  78.             header("Location: ". $MM_redirectLoginTecnico );
  79.            
  80.             }elseif($_SESSION['MM_UserGroup'] == 'tecnico'){
  81.            
  82.             header("Location: ". $MM_redirectLoginCliente );}
  83.            
  84.            
  85.        
  86.      
  87.      
  88.     } else {header("Location: ". $MM_redirectLoginFailed );}
  89.      
  90.     }
  91.     ?>
  #39 (permalink)  
Antiguo 20/12/2011, 19:23
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: seleccionar pagina dependiendo del usuario registrado

nada estimado... sigue apareciendo el mismo error...

agradezco de sobremanera todo tu esfuerzo y tiempo, pero tendre que buscar otra forma de realizar esto...
  #40 (permalink)  
Antiguo 21/12/2011, 12:48
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

la verdad no entiendo xq no te funciono , haber si alguien puede echar una mano y lo consigues
  #41 (permalink)  
Antiguo 21/12/2011, 18:05
 
Fecha de Ingreso: noviembre-2011
Mensajes: 121
Antigüedad: 12 años, 5 meses
Puntos: 0
Respuesta: seleccionar pagina dependiendo del usuario registrado

mira, hice una nueva pagina de inicio, mas simple, aca te dejo el link, ya que inicie un posteo nuevo...

http://www.forosdelweb.com/f18/inici...suarios-965625

Etiquetas: dependiendo, html, mysql, sql, variables, usuarios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:02.