-2

Possible Duplicate:
Headers already sent by PHP

I am using the header() function to redirect a user to some relative URI, e.g.:

header('Location:/Root/folder');

And everything works perfectly. However if I add Refresh:0; to the beginning of the header()'s parameter I get strange errors and I don't get redirected to the requested URI.

The errors I get are: some undefined POST variables which I use in the function with the header(), and the following arning:

Warning: Cannot modify header information - headers already sent by (output started at...

What is the problem? It doesn't work even with ob_start() and ob_end_flush() at the end...Meta tag doesn't work either, and I won't accept JS code in the PHP script.

Community
  • 1
  • 1
user1615069
  • 631
  • 4
  • 16
  • 26
  • 2 minutes eariler: Check out the next question , http://stackoverflow.com/questions/12884612/contact-form-php-redirect-is-not-working – Ofir Baruch Oct 14 '12 at 17:29
  • If you are echoing or printing something before the header then remove that and it will work.... the second option: you have a BOM in the document – rsz Oct 14 '12 at 17:33
  • Instead of showing half of your error messages and some of your code, give us what you have - otherwise you are only getting a lot of guesses and downvotes... – Repox Oct 14 '12 at 18:05

3 Answers3

1

This is the problem

header('Location:/Root/folder');

php header() requires the absolute path

Use

 header('Location: http://www.domain.com/Root/folder/something.php');
StaticVariable
  • 5,253
  • 4
  • 23
  • 45
1

dont forget http://

header('Location: http://www.domain.com/Root/folder/something.php');
Sergio Toledo Piza
  • 793
  • 1
  • 6
  • 27
0

Use die() after header() function.

s.webbandit
  • 16,332
  • 16
  • 58
  • 82