Código PHP:
Ver original<?php
require_once('Connections/localhost.php');
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
}
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;
}
}
$query_usuarios = "SELECT * FROM usuarios";
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_POST['user'])) { $loginUsername=$_POST['user'];
$password=$_POST['pass'];
$MM_fldUserAuthorization = "atri";
$MM_redirectLoginAdmin = "admins.php"; /*pagina de administradores*/
$MM_redirectLoginTecnico = "tecnicos.php"; /*pagina de tecnicos*/
$MM_redirectLoginClientes = "clientes.php"; /*pagina de clientes*/
$MM_redirectLoginFailed = "error.php"; /*pagina de error*/
$MM_redirecttoReferrer = false;
$LoginRS__query=sprintf("SELECT usuario, pass, atri FROM usuarios WHERE usuario=%s AND pass=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
if ($loginStrGroup ) {
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup['atri'];
if($_SESSION['MM_UserGroup'] == 'administrador'){
header("Location: ". $MM_redirectLoginAdmin );
}elseif($_SESSION['MM_UserGroup'] == 'cliente'){
header("Location: ". $MM_redirectLoginTecnico );
}elseif($_SESSION['MM_UserGroup'] == 'tecnico'){
header("Location: ". $MM_redirectLoginCliente );}
} else {header("Location: ". $MM_redirectLoginFailed );}
}
?>