Utilizando os exemplos da de Cookies e Sessões, ao tentar acessar o arquivo MENU.PHP diretamente digitando pelo browser, ele apresenta a mensagem:
Warning: Cannot modify header information - headers already sent by (output started at /home/espac356/public_html/cabecalho.php:13) in /home/espac356/public_html/logica-usuario.php on line 9
Agradeço a quem puder dar uma ajudinha
/*Arquivo MENU.PHP*/
<?php
require_once("logica-usuario.php");
require_once("cabecalho.php");
verificaUsuario(); ?>
<style>
.medio {
height: 70px;
}
</style>
<div class="col-xs-14"><hr></div>
<a href="form_usuario.php">
<button type="button" class="btn btn-primary btn-lg form-control medio">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span> Usuários
</button></a>
<br/>
<br/>
<a href="form_morador.php">
<button type="button" class="btn btn-primary btn-lg form-control medio">
<span class="glyphicon glyphicon-home " aria-hidden="true"></span> Moradores
</button></a>
<br/>
<br/>
<a href="form_avisos.php">
<button type="button" class="btn btn-primary btn-lg form-control medio">
<span class="glyphicon glyphicon-volume-up " aria-hidden="true"></span> Avisos
</button></a>
<?php require_once("rodape.php");?>
/* Arquivo CABECAOLHO.PHP*/
<html>
<head>
<title>Teste</title>
<meta charset = "utf-8"/>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"/>
</head>
<body>
<div class="container">
<div class="principal">
<img class="center-block" src="images/dez_rm_logo.png" class="img-responsive" alt="Teste">
/*Arquivo logica-usuario.php*/
<?php
session_start();
function usuarioEstaLogado() {
return isset($_SESSION["usuario_logado"]);
}
function verificaUsuario() {
if(!usuarioEstaLogado()) {
header("Location:index.php");
die();
}
}
function usuarioLogado() {
return $_SESSION["usuario_logado"];
}
function logaUsuario($email) {
$_SESSION["usuario_logado"] = $email;
}
/*Arquivo INDEX.PHP*/
<?php require_once("cabecalho.php");
?>
<h3 class="text-center">Bem-vindo!</h3>
<h4 class="text-center">Por favor, digite seu usuário e senha</h4>
<?php
if (isset($_GET["login"]) && $_GET["login"]==1) {
?>
<p class="alert-success text-center">Logado com sucesso</p>
<?php }
if (isset($_GET["login"]) && $_GET["login"]==0) {
?>
<p class="alert-danger text-center">Usuário ou senha inválidos</p>
<?php }
?>
<form class="form-horizontal" action="login.php" method="post">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">E-mail</label>
<div class="col-sm-10">
<input type="email" class="form-control" name="email" placeholder="E-mail">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Senha</label>
<div class="col-sm-10">
<input type="password" class="form-control" name="senha" placeholder="Senha">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary btn-default">Login</button>
</div>
</div>
</form>
<?php require_once ("rodape.php");?>