I have a login authentication system that is this:
<?php
if(isset($_POST['txtpass']))
{
session_start();
//variable de conexion: recibe dirección del host , usuario, contraseña y el nombre base de datos
$mysqli = new mysqli("localhost", "root", "", "bdpersona") or die ("Error de conexion porque: ".$mysqli->connect_errno);
// comprobar la conexión
if (mysqli_connect_errno())
{
printf("Falló la conexión: %s\n", mysqli_connect_error());
exit();
}
$login = $mysqli->real_escape_string($_POST['txtlogin']);
$pass = $mysqli->real_escape_string($_POST['txtpass']);
$resultado = $mysqli->query("SELECT * FROM tbusuario where login='$login' and pass='$pass' and activo!=0");
$valida=$resultado->num_rows;
if($valida != 0)
{
$datosUsu = $resultado->fetch_row();
$_SESSION['nombreusu'] = $datosUsu[3];
$_SESSION['perfil'] = $datosUsu[4];
echo "<META HTTP-EQUIV='Refresh' CONTENT='0; URL=listar.php'>";
}
else
{
echo
"<script>
var textnode = document.createTextNode('Usuario ó Password Incorrecto');
document.getElementById('msg').appendChild(textnode);
</script>";
}
}
?>
As you can see, if I accept the login and pass correctly, I take two values from the table where the login is and pass it and I save it in a variable session and I go to a page .php
$_SESSION['nombreusu'] = $datosUsu[3];
$_SESSION['perfil'] = $datosUsu[4];
When I go to the next page, which is list.php, I have this:
<?php
session_start();
if(isset($_SESSION['nombreusu']))
{
?>
<!----Todo el código---->
<?php
}
else
{
?>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=index.php">
<?php
}
?>
Well, in "All the code", I want to print $_SESSION['perfil']
And I do this:
<?php
$quieneres= $_SESSION['perfil']
echo $quieneres;
?>
And I get the following error:
Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:\xampp\htdocs\fondomarino\listar.php on line 419
Why can not I see the value per screen of the Session variable ???
Thank you very much.