SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to go to an URL

    Hi,

    I'm guessing that the answer to this question is farily simple, but I've browsed php.net several times and I can't seem to find the answer.

    What PHP code is used to go to an URL. Like, if some test is true, go to that specific URL.

    Thanks in advance !
    Sincerely,

    Eirik Johansen
    Netmaking AS

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
      if (isset($url)) {
        header("Location: $url");
      }
    Be warned! You cannot use the header() function if ANYTHING has been output to the browser yet -- the same as the setcookie() function.

  3. #3
    midnight coder
    Join Date
    Dec 2000
    Location
    The flat edge of the world
    Posts
    838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to redirect to a URL, header() is of course the best way, but if you want to send other data before the header(), you can use a meta-refresh...

    Code:
    if (isset($url))
        {
        ?>
        <meta http-equiv="refresh" content="0; url=<?=$url ?>">
        <?
        }


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
  •