View Full Version : Header Location
ukgrant
Jul 5th 2009, 8:44 am
Hi,
Is there a way or a different function that would allow me to send the user to another page.
(to my understanding, header location can only be used before output and is usless for my script)
thanks.
Dox5
Jul 5th 2009, 9:36 am
The easiest way would be with something like Java, as php is run before the page is displayed. The only way i can think of doing it with php is to refresh/reload the page and then redirect.
Bohra
Jul 5th 2009, 11:01 am
if u use the function obstart() then you can send the headers later aswell
SHOwnsYou
Jul 6th 2009, 8:40 am
<meta http-equiv content="timeinseconds;url=redirect url here">
or
<script type="text/javascript">
<!--
window.location = "redirect url here"
//-->
</script>
samyak
Jul 6th 2009, 3:39 pm
<meta http-equiv content="timeinseconds;url=redirect url here">
This has worked for me well.
www.amagit.com
Jul 6th 2009, 4:49 pm
For PHP... before you've written to the page:
<?php header("Location: http://www.example.com/");?>
You said that it is useless because you send output too soon... couldn't you possibly check if you must redirect before any output and then redirect right away?
Javascript is not always the best way because you can't be guaranteed that your user has it enabled, although the vast majority do.
hassanahmad2
Jul 7th 2009, 2:40 am
Use buffered output as bohra said earlier, its the only way through which you can call the header function later.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.