Log in

View Full Version : Redirect Problems



blm126
08-31-2006, 11:34 PM
I'm having problems with this function to redirect the user.


function redirect($url){
//This is a function to provide a safe and relible redirect
//send a 303 location header
header('Location: '.LINKBASE.$url,true,303);
//die with a click redirect
die('Sorry, you could not be redirected. Please <a href="'.LINKBASE.$url.'">click here</a>');
}

define LINKBASE(this is done before the function is called)


define('LINKBASE','http://localhost/cms/');

it is used here


function checkAuth($level,$url='index.php'){
if(!isset($_SESSION['yes'])){
session_start();
$_SESSION['yes'] = 'yes';
}
if(isset($_SESSION['auth']) && $_SESSION['auth'] <= $level){
return true;
}
else if(isset($_SESSION['auth']) && $_SESSION['auth'] > $level){
return false;
}
else{
redirect($url);
}
}

Whenever I run it Firefox(haven't checked other browsers) issues an error saying


Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

I'm sure I'm making some stupid mistake, but I would love to know what it is.

alexjewell
09-01-2006, 12:35 AM
shouldn't the header be called right after the opening php tags?

blm126
09-01-2006, 12:37 AM
shouldn't the header be called right after the opening php tags?
That's not the problem here unfortunately. I'm using output buffering