Example in code file index.php :
<header>
<input type="checkbox" id="btn-menu">
<label for="btn-menu" class="icon-menu"></label>
<nav class="menu">
<ul>
<li><a href="index.php"><span class="icon-home"></span>Home</a></li>
<li><a href="#"><span class="icon-info"></span>Sobre</a></li>
<li><a href="#"><span class="icon-calendar"></span>Agendamento</a></li>
</ul>
</nav>
<button type="button" class="cadastro btn-login"><a href="login-cadastro.php">Login</a></button>
<button type="button" class="cadastro btn-cadastro"><a href="login-cadastro.php">Cadastre-se</a></button>
</header>
When the user logs in, he wants the Login and Sign-up options to disappear, and instead of those options, the name of the user is displayed.
I was thinking of replicating the index.php code to the index-logado.php (example), and opening a session in that new code, putting his name there.
Example in code index-logado.php :
session_start();
<header>
<input type="checkbox" id="btn-menu">
<label for="btn-menu" class="icon-menu"></label>
<nav class="menu">
<ul>
<li><a href="index-logado.php"><span class="icon-home"></span>Home</a></li>
<li><a href="#"><span class="icon-info"></span>Sobre</a></li>
<li><a href="#"><span class="icon-calendar"></span>Agendamento</a></li>
</ul>
</nav>
echo "BEM-VINDO". $_SESSION['nome-usuario'];
</header>
I do not know if this is a correct way, it's the only one I thought, and I know so far.
If I had a condition that changed directly in the index.php would be the most practical solution to my view, but if it exists, I do not know it yet.
TRY N ° 1:
<?php session_start();
require_once("Valida.php");
?>
<header>
<input type="checkbox" id="btn-menu">
<label for="btn-menu" class="icon-menu"></label>
<nav class="menu">
<ul>
<li><a href="index.php"><span class="icon-home"></span>Home</a></li>
<li><a href="#"><span class="icon-info"></span>Sobre</a></li>
<li><a href="#"><span class="icon-calendar"></span>Agendamento</a></li>
</ul>
</nav>
<?php
if ($v->getValida()) {
?>
<span><?php echo "Bem-vindo ".$_SESSION['email']; ?></span>
<?php}else{?>
<button type="button" class="cadastro btn-login"><a href="login-cadastro.php">Login</a></button>
<button type="button" class="cadastro btn-cadastro"><a href="login-cadastro.php">Cadastre-se</a></button>
<?php } ?>
</header>
Validate.php file
<?php
class Valida{
private $valida;
function getValida(){
return $this->valida;
}
function setValida($valida){
$this->valida = $valida;
}
}
?>