Redirection error 'header ()' [duplicate]

0
<?php
require_once("banco-produtos.php");
require_once("logicaUsuario.php");
verificaUsuario();
require_once("header.php");

$id = $_POST['id'];

removeProduto($conexao, $id);
$_SESSION["success"] = "Produto removido com sucesso";
header("Location:estoque.php");
die();

LogicaUsuario.php

function verificaUsuario(){
    if (!usuarioEstaLogado()){
        $_SESSION["error"] = "Você não tem acesso a essa funcionalidade";
        header("Location:index.php");
        die();
    };
};

bank-products.php

require_once("conexao.php");
function removeProduto($conexao, $id){
    $query = "delete from produtos where id = {$id}";
    return mysqli_query($conexao, $query);
};

Error_log

Warning: Cannot modify header information - headers already sent by (output started at /home/comunica/public_html/testes/murilo/phpI/header.php:23) in /home/comunica/public_html/testes/murilo/phpI/remove-produto.php on line 11

I followed the tips given in two other questions, one of mine and one that had been marked as a duplicate of the previous one, but none of them solved my problem, I modified the code as many times as possible, tried to put header() or user verification.

    
asked by anonymous 06.12.2016 / 18:22

1 answer

1

I will try to explain the following error:

Warning: Cannot modify header information - headers already sent by (output started at /home/comunica/public_html/testes/murilo/phpI/header.php:23) in /home/comunica/public_html/testes/murilo/phpI/remove-produto.php on line 11

It says: "You can not modify the headers after you have already sent an outputbuffer."

By the previous post , in the header .php output buffers (HTML code), resulting in this warning.

Any Header modification must be done before any output, either include () , require () or even a echo with outputbuffer on.

    
06.12.2016 / 18:31