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!