Help - Search - Members - Calendar
Full Version: Header/HTML redirect function
Invision Power Services > Community Forums > Community Web Design and Coding
Bulk
I'm trying to come up with an all purpose function to redirect a user to another URL using either a header "Location" redirect or a meta refresh if html has already been sent to the browser. So, does anyone know a way to detect if html has already been sent to the browser so the function can decide which method to use?

Ta original.gif
Michael Boutros
Maybe:

CODE
if(!header("Location: http://www.anywhere.com")){
echo "<meta http-equiv='refresh' content='0;url=http://www.anywhere.com/'>";
}
Bulk
Excellent thanks I thought it'd be something simple biggrin.gif Altho I did need to put a @ on the header function otherwise it spits out a "headers already sent" error, appreciated though!

//Edit

Can't belive I missed this last night but I just found the headers_sent() function which does exactly what I needed it to do... guess that'll teach me to program t 6am eh? blink.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.