Header can not find the last destination

4

I'm working on a project and the header function can not find the destination passed to it. I have the following folder structure:

Inagivenform,Ipassactionto:

<formmethod="post" action="index.php?pagina=../controller/controllerCategoria">

So far so good, but what I would like is that when I got to that file, I would be able to return to a file within admin .

I was trying with the following header :

header('Location:http://localhost/tecmidiaCor/admin/index.php?pagina=criarPaginas');

In this case, I would like to go back to the file criarPaginas.php .

I have not put the% point of% because in my PHP I have a script that always assigns the contents of the page variable.

    
asked by anonymous 04.05.2015 / 00:21

1 answer

1

Well, I managed to solve it, what apparently happens is that my server in my application in the APACHE case starts to send the response of the requested request before actually arriving at the Header() function ie sending a body in the application layer in this case using the HTTP protocol this usually occurs by echo print functions or spaces before my PHP tags -- <?php found a function whose in ob_start it solves the problem because it holds this content before finalization. In my code I decided the following way, since I'm centralizing my application in '

<body> <?php
if (isset($_GET["pagina"])) {
    require ($_GET["pagina"] . ".php");
} else {
    echo "<h1>Bem vindo ao sistema</h1>";
}
?></body>

So bringing all the pages to the same top and footer, then there was a HTML code before starting this script, I imagine that the same would be sent before the HEADER() function itself, in fact the ideal would be to do test in reader of snifer as wireshark so I'm guessing that this happened, in my case I put the following code first of all in my index.php <?php ob_start(); ?> and my HEADER that was in another directory I just put it next way header("Location: index.php?pagina=criarPaginas") which redirects to another directory of my application, I thank everyone even @ Vinícius Gobbo A. de Oliveira

    
04.05.2015 / 02:44