Results 1 to 3 of 3

Thread: Redirect Problems

  1. #1
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Question Redirect Problems

    I'm having problems with this function to redirect the user.
    PHP Code:
    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)
    PHP Code:
    define('LINKBASE','http://localhost/cms/'); 
    it is used here
    PHP Code:
    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
    Quote Originally Posted by Firefox
    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.

  2. #2
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    shouldn't the header be called right after the opening php tags?

  3. #3
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Quote Originally Posted by alexjewell
    shouldn't the header be called right after the opening php tags?
    That's not the problem here unfortunately. I'm using output buffering

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •