Results 1 to 12 of 12

Thread: PHP Redirect

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218

    PHP Redirect

    I wanted to confirm something.

    Let's say that http://www.foo.com/index.php checks for a "Have you been here before cookie" and then redirects you to http://www.foo.com/foo/index.html. Is this correct, and if so, what does it do? Does it just simulate a meta tag, or do a server side switch?

    Code:
    <?php
      header("Location: /foo/index.html");
    ?>
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    That's wrong. It has to be the full URL like you would type in the Address box.

    It just simply tells the browser where to go and what page to load.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    Originally posted by The Hobo
    That's wrong. It has to be the full URL like you would type in the Address box.

    It just simply tells the browser where to go and what page to load.
    I have never had to use an absolute URL in the header("Location:") function. I normally just write index.html or something and it works great.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    I thought the documentation said the local address would work, but if it doesn't, I'll qualify it.

    But judging by Hobo's answer, the header function is sending a meta tag to the browser?

    If so, then I may just avoid using it. We'll see.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  5. #5
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    cpradio - Guess I should get my facts straight before I post, eh?

    Travis G - Why does it matter how it works? It sends the browser to the designated location.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  6. #6
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    I use the php version after a form was submitted so they cannot hit refresh and have all the data resent.
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    the header doesn't send a meta tag to the browser. close but no cigar. try putting the header tag anywhere in your document and I bet you get errors, with the meta tag you don't get any errors.

  8. #8
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Originally posted by The Hobo
    That's wrong. It has to be the full URL like you would type in the Address box.

    It just simply tells the browser where to go and what page to load.
    it doesnt have to be absolute,

    u can use all terms you can in the meta refresh,

    Its just like sending the page header's, like "Content : text/html"

    And then the browser goes to the new page

    --

    And most cases EVEN IF the person has disabled the IE meta refresh options
    Wayne

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by wpearsall
    it doesnt have to be absolute,

    u can use all terms you can in the meta refresh,

    Its just like sending the page header's, like "Content : text/html"

    And then the browser goes to the new page

    --

    And most cases EVEN IF the person has disabled the IE meta refresh options
    Yes. We've already discovered that I'm wrong. But thanks for ringing in a few days late.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    Why does it matter how it works? It sends the browser to the designated location.
    I just don't want the delay of two transactions, everytime someone loads the page.

    I wrote my site, and realized that I was using CSS 2, something that IE simply doesn't support. So I wanted to make a reduced version of my site for people with inferior browsers. I figured, once they visit the reduced site, a cookie will be set. Every time they visit, it will look for the cookie and direct them to the version they browsed last.

    I just don't want to delay everyone who is visiting. I just figure I'll have PHP pull in the page and show it to them, without redirecting.

    Thanks for the help though.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  11. #11
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by Travis G
    I just don't want the delay of two transactions, everytime someone loads the page.

    I wrote my site, and realized that I was using CSS 2, something that IE simply doesn't support. So I wanted to make a reduced version of my site for people with inferior browsers. I figured, once they visit the reduced site, a cookie will be set. Every time they visit, it will look for the cookie and direct them to the version they browsed last.

    I just don't want to delay everyone who is visiting. I just figure I'll have PHP pull in the page and show it to them, without redirecting.

    Thanks for the help though.
    The header() function would work great for this scenario. I don't see why you think it wont?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  12. #12
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Huh huh,

    IT bearly takes any time to use the header function

    its less then a split second,,

    B4 you relize you are at a new page, its happened...

    I.Explorer DOESNT EVEN RELIZE ITS BEING REDIRECTED IT HAPPENS SO FAST.
    Wayne

Posting Permissions

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



Click Here to Expand Forum to Full Width