function verificaUsuario() { if (!statusUsuario()) { $_SESSION['danger'] = "Você não tem acesso a essa funcionalidade"; header("Location: index.php?falha=true"); die; } }
<?php include "header.php"; include "logica-usuario.php"; mostraAlerta("success"); mostraAlerta("danger"); ?> <h1>Bem-vindo</h1> <?php if (statusUsuario()) { ?> <p class="alert-success">Você está logado como <?php echo nomeUsuario(); ?> . <a href="logout.php">Deslogar</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 class="btn btn-primary">Login</button></td>