Código PHP:
<?php
class UsuarioClass{
function validarUsuario($conexion, $cedula, $clave){
// ===
// Codigos
// 0: Datos Correctos
// 1: Cedula no existe
// 2: Clave incorrecta
// ===
$sql = "SELECT cCedula, cClave ";
$sql .= "FROM tusuario ";
$sql .= "WHERE cCedula='$cedula'";
$existe = false;
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result)) {
$existe = true;
break;
}
$codigoRetorno = "0";
if ($existe){
if ( $clave <> $row["cClave"]){
$codigoRetorno = "2";
}
}else{
$codigoRetorno = "1";
}
mysql_free_result($result);
return $codigoRetorno;
}
function validarperfil($cedula, $conexion)
{
$sql = "SELECT cJerarquia ";
$sql .= "FROM tusuario ";
$sql .= "WHERE cCedula ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result)){
$rol = $row['cJerarquia'];
}
return $rol;
}
function user($cedula, $conexion) {
if ($rol== "1"){
$sql = "SELECT cNombre ";
$sql .= "FROM tconfiguradores_proveedores ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$user = $row['cNombre'];
}
return $user;
}
elseif ($rol== "4"){
$sql = "SELECT cNombre ";
$sql .= "FROM tconfiguradores_proveedores ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$user = $row['cNombre'];
}
return $user;
}
elseif ($rol== "8"){
$sql = "SELECT cNombre ";
$sql .= "FROM tconfiguradores_proveedores_cx ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$user = $row['cNombre'];
}
return $user;
}
else {
$sql = "SELECT cNombre ";
$sql .= "FROM tconfiguradores_proveedores_dx ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$user = $row['cNombre'];
}
return $user;
}
}
function usera($cedula, $conexion) {
if ($rol== "1"){
$sql = "SELECT cApellido ";
$sql .= "FROM tconfiguradores_proveedores ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$usera = $row['cApellido'];
}
return $usera;
}
elseif ($rol== "4"){
$sql = "SELECT cApellido ";
$sql .= "FROM tconfiguradores_proveedores ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$usera = $row['cApellido'];
}
return $usera;
}
elseif ($rol== "8"){
$sql = "SELECT cApellido ";
$sql .= "FROM tconfiguradores_proveedores_cx ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$usera = $row['cApellido'];
}
return $usera;
}
else {
$sql = "SELECT cApellido ";
$sql .= "FROM tconfiguradores_proveedores_dx ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$usera = $row['cApellido'];
}
return $usera;
}
}
function codigo($cedula, $conexion) {
if ($rol== "1"){
$sql = "SELECT cCodConf1 ";
$sql .= "FROM tconfiguradores_proveedores ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$codconf = $row['cCodConf1'];
}
return $codconf;
}
elseif ($rol== "4"){
$sql = "SELECT cCodConf1 ";
$sql .= "FROM tconfiguradores_proveedores ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$codconf = $row['cCodConf1'];
}
return $codconf;
}
elseif ($rol== "8"){
$sql = "SELECT cCodConf1 ";
$sql .= "FROM tconfiguradores_proveedores_cx ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$codconf = $row['cCodConf1'];
}
return $codconf;
}
else {
$sql = "SELECT cCodConf1 ";
$sql .= "FROM tconfiguradores_proveedores_dx ";
$sql .= "WHERE cCarnet ='$cedula'";
$result=mysql_query($sql, $conexion);
while($row = mysql_fetch_array($result))
{
$codconf = $row['cCodConf1'];
}
return $codconf;
}
}
}
?>