Ver Mensaje Individual
  #6 (permalink)  
Antiguo 21/10/2013, 15:20
Avatar de zreep
zreep
 
Fecha de Ingreso: octubre-2009
Ubicación: Argentina
Mensajes: 534
Antigüedad: 15 años, 5 meses
Puntos: 12
Respuesta: No se si tengo un problema con sessiones

Hola Triby esto seria mas o menos asi?

Código PHP:
try {
    
$con = new PDO('mysql:host=localhost;dbname=basee','root','passs');
    }
catch (
PDOException $e){
    echo 
"Failed to get DB handle: ".$e->getMessage()."";
    exit;

Código PHP:
@session_start();

if(isset(
$_POST['enviar'])){
    if(!empty(
$_POST['user'])){
       
$stmt $con->prepare("SELECT * FROM usuario WHERE pass=:pass");
       
$stmt->execute(array(':pass'=>$_POST['user']));
       
$fila $stmt->fetch();       
            if(
$fila 0){
             
$_SESSION['logueado'] = "SI";
             
$_SESSION['usuario']  = $fila['nombre'];
            } else {
                echo 
'<div style="color: red; text-align: center;">Dato incorrecto</div>';
            }
    }

Código PHP:
if(isset($_SESSION['logueado']) && $_SESSION['logueado'] == "SI"){
    
$stm $con->prepare("SELECT * FROM usuario WHERE nombre=:logg");
    
$stm->execute(array(':logg'=>$_SESSION['usuario']));
    
//$fila = $stm->fetch();
    
if($stm->num_rows == 1) {
    
// También, al asignar fila tenías $stmt, sobrando la t final
    
$_SESSION['fila'] = $stm->fetch();

Código HTML:
datos del usuario... Hola <?=$_SESSION['usuario']?>, tu correo es: <?=$fila['mail']?> 
Me da error. Y no entendi bien el punto que me habias dicho!
__________________
Zreep