Capture the current page(url) into a variable?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Akhenaten

    Capture the current page(url) into a variable?

    What's the most effective way to capture a URL to pass as a variable?
    I have a login function I want to modify to redirect the user back to
    the page they logged in from. I know how to do the redirect, just
    uncertain of capturing the URL.

    TIA
    ../JLK

  • Rami Elomaa

    #2
    Re: Capture the current page(url) into a variable?

    Akhenaten kirjoitti:
    What's the most effective way to capture a URL to pass as a variable?
    I have a login function I want to modify to redirect the user back to
    the page they logged in from. I know how to do the redirect, just
    uncertain of capturing the URL.
    >
    TIA
    ./JLK
    >
    Study the output of <?php print_r($_SERVE R); ?>. It's $_SERVER['...']
    something, I don't remember the exact key, but you'll see the complete
    list there.

    --
    Rami.Elomaa@gma il.com

    "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
    usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

    Comment

    • Jon Slaughter

      #3
      Re: Capture the current page(url) into a variable?


      "Akhenaten" <jonkokko@gmail .comwrote in message
      news:1179772114 .192174.188640@ 36g2000prm.goog legroups.com...
      What's the most effective way to capture a URL to pass as a variable?
      I have a login function I want to modify to redirect the user back to
      the page they logged in from. I know how to do the redirect, just
      uncertain of capturing the URL.
      >
      >
      You could store the last page they came from using $_SERVER['HTTP_REFERER']
      or you could include some code to keep a FIFO buffer of the last pages
      visted(asusming you only want to return to pages on your own site).


      So something like

      array_push($Las tPages, __Current_Page_ _);

      and then you can access the previous pages.

      Theres probably better ways though....


      Comment

      • Carl

        #4
        Re: Capture the current page(url) into a variable?

        Akhenaten <jonkokko@gmail .comwrites:
        What's the most effective way to capture a URL to pass as a variable?
        I have a login function I want to modify to redirect the user back to
        the page they logged in from. I know how to do the redirect, just
        uncertain of capturing the URL.
        >

        You might want to have a look at the value of:
        $_SERVER['REQUEST_URI']

        Remember that these values are provided by the webserver, so
        no guarantee is made that $_SERVER vars will be
        available, but in practice they usually are.

        Hope that helps,
        Carl.

        Comment

        • Akhenaten

          #5
          Re: Capture the current page(url) into a variable?

          On May 21, 1:37 pm, Rami Elomaa <rami.elo...@gm ail.comwrote:
          Akhenaten kirjoitti:
          >
          What's the most effective way to capture a URL to pass as a variable?
          I have a login function I want to modify to redirect the user back to
          the page they logged in from. I know how to do the redirect, just
          uncertain of capturing the URL.
          >
          TIA
          ./JLK
          >
          Study the output of <?php print_r($_SERVE R); ?>. It's $_SERVER['...']
          something, I don't remember the exact key, but you'll see the complete
          list there.
          >
          --
          Rami.Elo...@gma il.com
          >
          "Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
          usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze

          Thx! The variable was $_SERVER['SCRIPT_NAME'];

          Comment

          Working...