Web Hosting Talk







View Full Version : redirect with php


IQStudio
03-04-2003, 08:26 PM
How do you redirect with php? I have tried the header function but the headers are already sent. I just get the headers are already sent message.

machine
03-04-2003, 08:46 PM
try this at the very top of your page

<? ob_start(); ?>

Khaless
03-04-2003, 09:22 PM
u can use ob_start and ob_clean to controll the output, or u can just put the things in the right places. either way it will work.

t c
03-04-2003, 10:58 PM
Or you could do something like...

<?php
$redirect_url = "newpage.php";

if ($redirect == "yes"){
?><meta http-equiv="refresh" content="0; url=<?echo $redirect_url;?>""><?
} else {
echo "hi";
}

?>


..the meta refresh is the redirection example, you could also replace that with a javascript code to set the href.location = $redirect_url