SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: forward to url

  1. #1
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    forward to url

    is there another way to forward to an URL instead of using header("location: URL")?

    because i personally find having to send the header before everything else a pain in the ****
    hmm...

  2. #2
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use a meta-refresh tag:
    Code:
    	<meta http-equiv="refresh" content="<?=$delay?>; url=<?=$url?>">

  3. #3
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the trouble ive found with the meta refresh tag is that i have to include it in the <head></head> tags

    anything else?
    hmm...

  4. #4
    SitePoint Addict IsaacV's Avatar
    Join Date
    Jan 2002
    Location
    Saint Petersburg
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, there's always clumsy old javascript...
    Pants.
    Join the NYFlava Fashions Contest

  5. #5
    Super Ninja Monkey Travis's Avatar
    Join Date
    Dec 2001
    Location
    Sioux City, Iowa
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could use ob_start() and then use Header('Location: page.php'); anywhere in the file. just make sure ob_start() is at the top.
    Travis Watkins - Hyperactive Coder
    My Blog: Realist Anew
    Projects: Alacarte - Gnome Menu Editor

  6. #6
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by CHeeSeBLiND
    the trouble ive found with the meta refresh tag is that i have to include it in the <head></head> tags
    as an aside: why is including this in the <head> tags a problem?

  7. #7
    SitePoint Addict whofarted's Avatar
    Join Date
    Aug 2001
    Location
    lost, If you find me please return me to St.Louis
    Posts
    396
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually I though that to but I found it (at leasts in 4.0 & later browsers) you can actually put that

    PHP Code:
    <meta http-equiv="refresh" content="<?=$delay?>; url=<?=$url?>">
    Anywhere in the page. Try it out.
    You smell something?

  8. #8
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the trouble with me including the meta in the <head> is that in my site i include my header and footer and then header goes past the <head></head> tags
    hmm...

  9. #9
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for me what i do is i've 2 functions which echoes a normal html header, and the other which echoes a header with the meta-refresh tag if i want the page to redirect...

    PHP Code:
    <?php
    ///////////////////////////////////////////////////////////////////////////////
    // Function: void pageheader(string $title="OpenBook", string $body_attr="")
    // Purpose: echoes html page header
    // Parameters:
    //    $title - title of page (default: OpenBook)
    //    $body-attr - additional body attributes (default: empty string)
    // Returns: nothing
    // Global references: none
    ///////////////////////////////////////////////////////////////////////////////
    function pageheader($title="OpenBook"$body_attr="")
    {
    ?>
    <html>
    <head>
        <title><?=$title?></title>
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="expires" content="-1">
        <meta http-equiv="cache-control" content="no-cache">
        <link rel="stylesheet" type="text/css" href="<?=$GLOBALS['OB_css']?>">
    </head>
    <body <?=$body_attr?>>
    <?php
    }// end pageheader()

    ///////////////////////////////////////////////////////////////////////////////
    // Function: void redirectheader(string $url="./index.php", int $delay=2)
    // Purpose: html page header for redirection
    // Parameters:
    //    $url - URL to redirect to (default: ./index.php)
    //    $delay - time in seconds to wait before redirection (default: 2)
    // Returns: nothing
    // Global references:
    //    $sitename - name of site
    ///////////////////////////////////////////////////////////////////////////////
    function redirectheader($url="./index.php"$delay="2")
    {
    ?>
    <html>
    <head>
        <title><?=$GLOBALS["sitename"]?></title>
        <meta http-equiv="refresh" content="<?=$delay?>; url=<?=$url?>">
        <link rel="stylesheet" type="text/css" href="style.css">
    </head>
    <body>
    <?php
    }// end redirectheader()

  10. #10
    The Jellophonic Autobrain CHeeSeBLiND's Avatar
    Join Date
    Jul 2001
    Location
    Bolton, England
    Posts
    584
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ive added a function to my function list:
    PHP Code:
    function forward($url) {

    ?>    
    <html>    
    <head>    
    <meta http-equiv="refresh" content="0; url=$url"> 
    </head>    
    <body>    
    </body>    
    </html>    
    <?    
    exit;

    }
    and then when i want to forward to a page is just use forward("http://www.sitepointforums.com"); or whatever
    hmm...


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
  •