Error - Warning: Cannot Modify header information

Asked

Viewed 14 times

0

I’m trying to make a footer on the site with access to the bank to show the logged in user, but when soon gives this error, I already searched and could not solve.

my footer:

<?php

if (!isset($_SESSION)) {
    session_start();
}
if ((!isset($_SESSION['usuario']) == TRUE) && (!isset($_SESSION['senha']) == TRUE) && (!isset($_SESSION['id']) == TRUE) && (!isset($_SESSION['perfil']) == TRUE) && (!isset($_SESSION['nome']) == TRUE)) {
    session_unset();
    session_destroy();
    header('location: login.php');
}

include './conexao.php';

$nome = $_SESSION['nome'];
$id = $_SESSION['id'];
$select = "SELECT pu.descricao "
        . "FROM perfil_usuario pu "
        . "INNER JOIN login lo ON lo.perfil = pu.id "
        . "WHERE lo.id = '$id'";
$result = mysqli_query($conexao, $select);
$linha = mysqli_fetch_array($result);
?>

<div id="footer">
    <label id="label"><?php echo $nome . ' - ' . $linha['descricao'] ?></label>
</div>

I’m calling it that at the end of my html content:

<?php include './rodape.php'?>

If I take the snippet from include './connected.php'; it works without error.

  • Such a.php connection must have some space or other and must also have headers. See: https://answall.com/a/18812/3635

  • Exactly, the connection has a header with charset, how do I put the charset now?

  • Put before the space that should exist within your.php connection, see: https://answall.com/a/18812/3635

  • the session and headers must be started before any output from php to the screen. if you have any print or even a space before that, this error will be displayed.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.