0

I have a php script that outputs a confirmation text and redirects using header to a certain page after i log in. The script is working fine on mozilla and internet explorer but fails to redirect me on chrome and opera without showing any warnings or errors (even though i enabled them in php ini). I also tried a simple redirect like this:

<?php
header("refresh:2 url=http://localhost/KKK/home.php");
?>

It works on mozilla and ie but fails on the other two. Redirecting using only location without refresh is working on all of them. What is the problem? Thanks in advance.

kero
  • 10,647
  • 5
  • 41
  • 51
user3057352
  • 5
  • 1
  • 4

1 Answers1

2

This should be the correct syntax:

header( "refresh:5;url=wherever.php" );

Source: php.net

Predrag Beocanin
  • 1,402
  • 3
  • 18
  • 25
  • No no no! Headers should always contain absolute URIs! And if it doesn't work with an absolute, it won't work with a relative - so this isn't really an answer. Also quoting a comment from the doc and the doc itself is quite different (I know you didn't specify either but it is implied) – kero Feb 25 '14 at 15:01
  • I was refering to the lack of semicolon at the end of `refresh:x;`. – Predrag Beocanin Feb 25 '14 at 15:03
  • Ok then I am sorry but that wasn't clear to me (still my point about relative URIs stands) – kero Feb 25 '14 at 15:04
  • 1
    Yup, I wasn't suggesting to use a relative one. I make systems that get migrated a lot, so personally I use relative (so that whoever is migrating it doesn't have to go through all the code), but I do support your point with the absolute. =) – Predrag Beocanin Feb 25 '14 at 15:17