1
How can I change the message from "Log in" to "Welcome, User X". On the index.html page.
in index. html is like this
<p class="login"><b><a href="login.php">Faça o seu login!</a></b></p>
after the typed data is passed to the validator
<form class="form-signin" method="POST" action="valida.php">
and validates this if the login is successful :
if(isset($resultado)){
$_SESSION['usuarioId'] = $resultado['id'];
$_SESSION['usuarioNome'] = $resultado['nome'];
//$_SESSION['usuarioNiveisAcessoId'] = $resultado['niveis_acesso_id'];
$_SESSION['usuarioEmail'] = $resultado['email'];
if($_SESSION['usuarioId'] == $resultado['id']){
header("Location: index.php");
}
still could not display the welcome messages just back to index, saved as index.php and put the code:
– user149711
<?php if (isset($_SESSION['usuarioNome'])) { echo '<p class="example"><b><a href="">Welcome, User '.$_SESSION['usuarioNome']. '</a></b></p>'; } Else{ echo '<p class="login"><b><a href="login.php">Log in! </a></b></p>'; } ?>
– user149711
already has session_start() in your project?
– Larissa silva
I will not test now with session_start();
– user149711
puts it before the following line-> $_SESSION['userId'] = $result['id'];
– Larissa silva
Thank you very much. I tested it here, first log in, then it appears the name of the user I logged only. God bless you for the help!
– user149711
You’re welcome. Kindly mark the answer as you accept.
– Larissa silva
It is noteworthy that the
session_start();
should be before any output of php to the browser (usually at the first of the file just after the tag<?php
) to avoid errorHeaders already sent
– Vinicius.Silva