1

When I add the php redirect command in an include file, it redirects just that area, in its little sub window.

How can I make a redirect work with the base page?

Is it even possible, because you can only redirect before the headers, can't you? Would I have to use javascript instead?

1
  • Do You use frames, iframes, html objects or something like this? Commented Feb 6, 2012 at 13:48

2 Answers 2

1

If you are not talking about iframes

You can use output buffering to get round this issue. At the beginning of your main script run:

ob_start();

And then once you are done at the bottom of your main script run:

ob_end_flush();

From the manual page linked above:

This function will turn output buffering on. While output buffering is active no output is sent from the script (other than headers), instead the output is stored in an internal buffer.

The contents of this internal buffer may be copied into a string variable using ob_get_contents(). To output what is stored in the internal buffer, use ob_end_flush(). Alternatively, ob_end_clean() will silently discard the buffer contents.

Sign up to request clarification or add additional context in comments.

Comments

0

If you want to redirect parent window from <iframe (I assume that's what you mean by "little sub window") you have to use javascript, probably: self.parent.location.href = '...';

Google for javascript parent redirect to get more examples.

2 Comments

Nah im not using frames, I just meant the include is like its own little window.
That the Treffynnons answer is right and you could use Header( 'Location: ') any time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.