Ver Mensaje Individual
  #23 (permalink)  
Antiguo 19/12/2011, 13:03
webankenovi
Invitado
 
Mensajes: n/a
Puntos:
Respuesta: seleccionar pagina dependiendo del usuario registrado

ponlo asi tal cual con session_start(); si no no funcionara

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