
29/08/2009, 13:07
|
| | Fecha de Ingreso: agosto-2009
Mensajes: 17
Antigüedad: 15 años, 6 meses Puntos: 0 | |
Respuesta: Redirigir a los usuarios al iniciar sesión según su nivel Lo que tenia originalmente erá este codigo:
<?php require_once('Connections/CasaRealconn.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;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
}
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
if (isset($_POST['usuario'])) {
$loginUsername=$_POST['usuario'];
$password=$_POST['contrasena'];
$MM_fldUserAuthorization = "nivel";
$MM_redirectLoginSuccess = "Admi.php";
$MM_redirectLoginFailed = "mal.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_CasaRealconn, $CasaRealconn);
$LoginRS__query=sprintf("SELECT nombre_usuario, contrasena, nivel FROM usuarios WHERE nombre_usuario=%s AND contrasena=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $CasaRealconn) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = mysql_result($LoginRS,0,'nivel');
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
}
header("Location: " . $MM_redirectLoginSuccess );
}
else {
header("Location: ". $MM_redirectLoginFailed );
}
}
?>
con este formulario de conectar al ususrio, esta con post
<form id="IniciarSecc" name="IniciarSecc" method="POST" action="<?php echo $loginFormAction; ?>">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td align="right" valign="middle"> </td>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td align="right" valign="middle">Nombre del Usuario:</td>
<td align="left" valign="middle"><input name="usuario" type="text" id="usuario" size="50" maxlength="50" /></td>
</tr>
<tr>
<td align="right" valign="middle">Contraseña:</td>
<td align="left" valign="middle"><input name="contrasena" type="password" id="contrasena" size="50" /></td>
</tr>
<tr>
<td align="right" valign="middle"><input type="submit" name="button" id="button" value="Iniciar" /></td>
<td align="left" valign="middle"><input type="reset" name="button2" id="button2" value="Restablecer" /></td>
</tr>
</table>
</form>
pero solo envía a la página Admi.php. Quizás no supe donde colocar lo que me dijiste, ya me volví un 8, no se si se explicarme |