Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/02/2013, 14:41
briana
 
Fecha de Ingreso: febrero-2013
Mensajes: 16
Antigüedad: 11 años, 2 meses
Puntos: 0
Pregunta como agregar linea para autenticar sesion de administrador??

Hola buena tarde a todos. Soy nueva en php. Estoy diseñando un sitio y hasta el momento ya esta el codigo (sinceramente lo he hecho reusando codigo de la red) funcionando bien, solo me falta que el script index.php valide al administrador y lo envie a su página para tener el control del contenido de la web. Este es el código integro del index (logeo). Donde debo hacerlo y como?? toy perdidaa....Gracias por su apoyo en Pro del conocimiento. saludos gracias..

php require_once('Connections/conex_sedesol.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
// *** Validamos la solitud de logueo.
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=$_POST['PASS'];
$MM_fldUserAuthorization = "priv";
$MM_redirectLoginSuccess = "superv.php";
$MM_redirectLoginFailed = "index.php";
$MM_redirecttoReferrer = false;

mysql_select_db($database_sedesol, $sedesol);

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

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

$loginStrGroup = mysql_result($LoginRS,0,'priv');

//declaramos 2 variables de seion y las asignamos
$_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 );
}
}
?>

Última edición por briana; 21/02/2013 a las 14:43 Razón: error