Ver Mensaje Individual
  #1 (permalink)  
Antiguo 22/07/2011, 15:50
Avatar de Briss
Briss
 
Fecha de Ingreso: junio-2011
Mensajes: 1.293
Antigüedad: 13 años, 5 meses
Puntos: 12
Logueo varios tipos de usuario

Hola amigos aqui de nuevo molestando jejeje necesito hacer un logueo para diferentes tipod de usuario he modificado un codigo pero siempre me marca error (apesar de que el usuario si esta registrado)

Código HTML:
<?php require_once('Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
$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;
}
}

$colname_loging = "-1";
if (isset($_POST['nombre'])) {
$colname_loging = $_POST['nombre'];
$colname_pass = $_POST['pass'];
}
 mysql_select_db($database_connection, $connection);
 $LoginRS__query=sprintf("SELECT nombre, pass, tipo FROM usuarios_sistema WHERE nombre = %s", GetSQLValueString($colname_loging, "text"));
  $LoginRS = mysql_query($LoginRS__query, $connection) or die(mysql_error());
 $loginFoundUser = mysql_num_rows($LoginRS);
?>
<?php

if (!isset($_SESSION)) {
session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['nombre'])) {
$loginUsername=$_POST['nombre'];
$password=md5($_POST['pass']);
$MM_fldUserAuthorization = "row_loging['tipo']";
 $MM_redirectLoginSuccess = "default.php";
  $MM_redirectLoginSuccess = "default2.php";
  $MM_redirectLoginFailed = "fail.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_connection, $connection);

$LoginRS__query=sprintf("SELECT nombre, pass, tipo FROM usuarios_sistema WHERE nombre=%s AND pass=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 

  $LoginRS = mysql_query($LoginRS__query, $connection) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;	

if (isset($_SESSION['PrevUrl']) && true) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
}
switch($row_loging['tipo'])
{
case "administrador":    header("Location: " . $MM_redirectLoginSuccess );
break;
case "docente": header("Location: " . $MM_redirectLoginSuccess2 );
break;
}
}else {
 header("Location: ". $MM_redirectLoginFailed );
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="es-ES">
<head>
	<title>Inicias Sesión</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	
<link rel="stylesheet" type="text/css" href="css/login.css"/>
<link rel="stylesheet" type="text/css" href="css/colors-fresh.css"/>
</head>
<body class="login">

<div id="login"><h1><a href="http://wordpress.org/" title="Generado con WordPress">ejemplo</a></h1>

<form name="loginform" id="loginform" action="<?php echo $loginFormAction; ?>" method="POST">
	<p>
		<label>Nombre de usuario<br />
		<input type="text" name="nombre" id="nombre" class="input" value="" size="20" tabindex="10" /></label>
	</p>
	<p>
		<label>Contraseña<br />
		<input type="password" name="pass" id="pass" class="input" value="" size="20" tabindex="20" /></label>

	</p>
	<p class="submit">
	  <input type="submit" name="wp-submit" id="wp-submit" value="Iniciar sesión" tabindex="100" />
		<input type="hidden" name="redirect_to" value="default.php" />
		<input type="hidden" name="testcookie" value="1" />
	</p>
</form>

<p id="nav">

</p>

</div>



<script type="text/javascript">
try{document.getElementById('user_login').focus();}catch(e){}
</script>
</body>
</html> 

ojala me puedan orientar que esta mal...