inthezone
02-27-2003, 01:44 AM
I'm writing a conditional script that uses vB's global.php, and I'm attempting to redirect unregistered users to the user cp login screen. However, since I am using a header include on the page, I get a Cannot modify header information - headers already sent error. I've tried commenting out the line that requires the header, and the redirect works fine. With the require line intact, I get the error and no redirect.
<?php
chdir('/path/to/forums/');
require('./global.php');
require('/path/to/header.php');
if ($bbuserinfo['usergroupid']==1)
{
header("Location: http://www.mydomain.com/forums/usercp.php");
exit;
}
else
{
echo "Welcome back, ".$bbuserinfo['username']."!";
}
require('/path/to/footer.php');
?>
How can I get it to redirect properly while still using the header? (BTW, header.php and footer.php are strictly HTML with no php code inside.)
Edit-I guess putting the header and footer requires in the "else" part of the conditional would work. Is there another way to do this that I am missing?
<?php
chdir('/path/to/forums/');
require('./global.php');
require('/path/to/header.php');
if ($bbuserinfo['usergroupid']==1)
{
header("Location: http://www.mydomain.com/forums/usercp.php");
exit;
}
else
{
echo "Welcome back, ".$bbuserinfo['username']."!";
}
require('/path/to/footer.php');
?>
How can I get it to redirect properly while still using the header? (BTW, header.php and footer.php are strictly HTML with no php code inside.)
Edit-I guess putting the header and footer requires in the "else" part of the conditional would work. Is there another way to do this that I am missing?