Utilizo eso:
Código PHP:
Ver original<?php
//Inicio la sesión
$user=$_POST["user"];
$pass=$_POST["pass"];
$link =$_POST["link"];
if($link == "")
$link = "/";
$_SESSION["DisplayLoginError"] = "N";
//Comprobamos si el usuario está auttenticado
if ($_SESSION["autenticado"] != "Y"){
require ("Connections/db.inc.php");
require ("classes/user.class.php");
$dblink = db_connect();
// The username is unique, therefore we only can have one record.
$queryValidaUser = "SELECT IdUsuario, Nombre, Apellidos, Password, Username, Direccion, Postal, Poblacion, Ciudad, Telefono, Dni, Informacion FROM Usuario WHERE Username = '" . $user . "'";
$userData = getOneRow($queryValidaUser);
$_SESSION["DisplayLoginError"] = "Y";
//if($userData = mysql_fetch_assoc($userDataRS)){
if($userData){
if ($pass == $userData['Password']){
$_SESSION["autenticado"] = "Y";
/*$_SESSION["Name"] = $userData['Apellidos'] . ", " . $userData['Nombre'];
$_SESSION["School"] = $userData['Colegio'];*/
$_SESSION["User"] = User::createUserFromRS($userData);
$_SESSION["DisplayLoginError"] = "N";
}
}
db_disconnect($dblink);
}
?>