Do not redirect

0

I have the code below at the beginning of a page. I'm going for it without passing ID by GET, so it's entering ELSE correctly. It is passing through the setFlash, but does not redirect the page through the location. It stays on the same page. What can it be?

<?php 
    if(!empty($_GET['id'])){
        $id = $_GET['id'];
        $estabelecimentoDao = new EstabelecimentoDAO(); 
        $estabelecimentos = $estabelecimentoDao->all(); 
        $agendaDao = new AgendaDAO();
        $teste = $agendaDao->first($id);
    }else{
        $flash = new Flash();
        $flash->setFlash('Para editar você precisa passar um ID Válido</br>', 'alert-danger');
        header('Location:../../View/Agenda/index.php');
    }
?>
    
asked by anonymous 08.03.2017 / 14:23

1 answer

0

According to the PHP documentation:

  

Remember that the header () must be called before any content   is sent, either by HTML tags, blank lines in a file or by PHP itself.

So, do not make alerts on the screen, as the header will not work.

    
22.05.2017 / 18:44