PHP redirect [duplicate]

0

Next, I created a page to edit a content, and I would like it to return to the previous page by clicking the refresh button. I am using the following command:

header("Location: visualizarNovaPrevisao.php");

However, a warning appears:

  

Warning: Can not modify header information - headers already sent by   (output started at C: \ Program Files   (x86) \ VertrigoServ \ www \ marco \ php \ editNewPreview.php: 276) in

I have read about this warning, but I do not understand what they say about output at line 276. Does anyone know how I can use redirection?

    
asked by anonymous 28.10.2014 / 16:43

4 answers

0

1) Find the header () statement that is causing the problem. The error should be the same as above.

2) Look for all statements that could send the output to the user before this header declaration. If you find one or more, find some way to move the header declaration before them. Complex conditional statements can complicate the problem, but they can also help solve the problem. Consider a conditional expression at the beginning of the PHP script that determines the header value as early as possible, and fixes it there.

3) Make sure there is no white space outside the beginning and end of php tags. As long as a blank line before the

4) An important detail, publishers with UTF-8 support such as DWCS4 and Eclipse save the .php file with Unicode Signature (BOM), just uncheck this option, save it and fix it.

    
28.10.2014 / 16:46
0

You forgot the href -

function voltar () { 

    window.location.href="http://www.google.com.br   ou  seu caminho da pagina" ;
}

button and

<input type="button" onclick="voltar()">
    
28.10.2014 / 17:48
0

The error is occurring because it is not possible to send the header after the contents of the file.

Somewhere before header() exists either an html tag, a echo or even a blank space outside <?php ?> .

It shows the error in the file editaNovaPrevisao.php in line 276, because that is where a content was written to the file.

If you can not remove or modify the place of the data output you will have to redirect through JavaScript.

On this other question you will find a more detailed explanation of what might cause this error:

Error - "Can not modify header information - headers already sent" / a>

    
28.10.2014 / 17:57
-1

If you have Dreamweaver, it should be saving a few more characters at the beginning of your code. Do the following: Open your php file and go to Save As and uncheck the option: Include Unicode Signature (BOM). If it still persists, open the script in Notepad ++ and remove the existing characters at the beginning of the code.

    
28.10.2014 / 18:11