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

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);
         
         
        
$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_redirectLoginAdmin "admins.php";
          
$MM_redirectLoginTecnico "formtecopt.php";  
          
$MM_redirectLoginCliente ="AQUI LA PAGINA DE REDIRECCION DE CLIENTES";
          
$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_fetch_array($LoginRS);
     
          if (
$loginFoundUser) {
           
            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'] = $loginFoundUser['atri'];        
         
         
             if (isset(
$_SESSION['MM_UserGroup']) == 'administrador') {
               
                  
header("Location: "$MM_redirectLoginAdmin );
           
            }elseif(isset(
$_SESSION['MM_UserGroup']) == 'tecnico'){
               
                  
header("Location: "$MM_redirectLoginTecnico );
               
                 }elseif(isset(
$_SESSION['MM_UserGroup']) == 'cliente'){
                     
                 
header("Location: "$MM_redirectLoginCliente );
                 
                 }else{  
                 
                 
header("Location: "$MM_redirectLoginFailed ); }
         
          }else {
            
header("Location: "$MM_redirectLoginFailed );
          }
        }
        
?>