Well I've got a website, in the header of this website I've got two links, one to login and another one to register. I want that, when the user is logged in, those two links disappear, so i can have one saying "Hello " followed by a link to the control panel. like "Hello . . The thing is that it isn't searching the name of the user. It just doesn't show the name. The user is logged with the email and password, and the function usuarioEstaLogado()
is the one that confirm the user is logged. Here's the codes:
function nomeUsuario($conexao){
$usuarios = array();
$query = "select nome from usuarios where email = '{$mail}'";
$resultado = mysqli_query($conexao, $query);
while($usuario = mysqli_fetch_assoc($resultado)){
array_push($usuarios, $usuario);
}
return $usuarios;
}
<?php
session_start();
function usuarioEstaLogado() {
return isset($_SESSION["usuario_logado"]);
}
<div class="container container-twelve">
<header>
<div class="twelve columns top remove-bottom">
<div class="three columns offset-by-nine">
<?php
if(usuarioEstaLogado()){
$usr = nomeUsuario($conexao);
echo" <p>Ola " . $usr['nome'];
"<a href='admin'> Painel de Controle</a></p>";
}
?>
<p><a href="cadastro.php">Cadastre-se</a> |
<a href="login.php">Login <span class="icon-user"></span></a></p>
</div>