Pessoal, estou com um problema, refatorei o código de "mostra-alerta", porém na pagina index ele não exibe as mensagens, para exibir preciso chamar as funções na pagina mesmo. Abaixo segue o código do index, cabeçalho e mostra alerta.
<?php
include("cabecalho.php");
include("logica-usuario.php");
?>
<?php
//funções do mostra-alerta
mostrarAlerta("success");
mostrarAlerta("danger");
?>
<h1>Bem-vindo!</h1>
<?php
if(usuarioEstaLogado()) {
?>
<p class="text-success">Você está logado como <?= usuarioLogado() ?> <a href="logout.php">Sair</a></p>
<?php
} else {
?>
<h2>Login</h2>
<form action="login.php" method="post">
<table class="table">
<tr>
<td>Email</td>
<td><input class="form-control" type="email" name="email"></td>
</tr>
<tr>
<td>Senha</td>
<td><input class="form-control" type="password" name="senha"></td>
</tr>
<tr>
<td><button type="submit" class="btn btn-primary">Login</button></td>
</tr>
</table>
</form>
<?php
}
?>
<?php
include("rodape.php");
?>
insira seu<?php error_reporting(E_ALL ^ E_NOTICE); include("mostra_alerta.php"); ?> <!doctype html>
Home
<?php mostrarAlerta("danger"); mostrarAlerta("success"); ?> código aqui
<?php
session_start();
function mostrarAlerta($tipo){
if(isset($_SESSION[$tipo])) {
?>
<p class="alert-<?=$tipo?>"><?=$_SESSION[$tipo]?></p>
<?php
unset($_SESSION[$tipo]);
}
}