0

This is my url: http://server.com/index.php?module=purchases&ticket=12345&getPO=true

<?php
if ($_GET['getPO'] == "true"){
   header("Location:http://google.com");
      echo "Here";
    }else{
      /other stuff...
}

In the above code I see "Here" but I do not get redirected to url. What am i missing? I have confirmed there is no other text being sent to browser, no white space,etc....

samayo
  • 16,163
  • 12
  • 91
  • 106
bart2puck
  • 2,432
  • 3
  • 27
  • 53
  • You can't have anything above it, not even whitespace – Machavity Aug 04 '17 at 19:27
  • 1
    you can add exit after header like: header("Location:http://google.com"); exit; – Tanseer UL Hassan Aug 04 '17 at 19:28
  • There's no whitespace above it. – bart2puck Aug 04 '17 at 19:29
  • First before `header("Location:")` you should not send any other `header` or `echo` , second after `header("location: ")` add `exit` – aidinMC Aug 04 '17 at 19:29
  • This is not a duplicate. Where in my question do I say anything about any headers already sent error? – bart2puck Aug 04 '17 at 19:30
  • @bart2puck There must not be even a single space before ` – samayo Aug 04 '17 at 19:30
  • @bart2puck Have you turned error notification on? I still think this is a header redirect error, but with error turned off. – samayo Aug 04 '17 at 19:34
  • Make sure you have enabled error reporting for warnings. You probably do have an output before the `header()` but don't see a warning. – masterfloda Aug 04 '17 at 19:35
  • 1
    Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file. – andreas karimi Aug 04 '17 at 20:06

0 Answers0