I know this question has come up before and i've researched headers and i know that you can't output anything to the browser then change the headers, so my question is, is there a way to redirect with PHP inside a HTML document?

Recommended Answers

All 3 Replies

The only way to do this would be to have the header() at the top, before any output on the page.

What exactly are you trying to do?

Maybe you can output a javascript function that can redirect, and put the call in html when necessary.

echo a meta refresh in the head of the document if certain conditions exist.

if(empty($_SESSION['ID'])){
echo'<meta http-equiv="refresh" content="0;url=http://www.yoursite.com/newpage.htm" />';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.