By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,830 Members | 2,182 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,830 IT Pros & Developers. It's quick & easy.

Capture the current page(url) into a variable?

P: n/a
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

May 21 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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($_SERVER); ?>. It's $_SERVER['...']
something, I don't remember the exact key, but you'll see the complete
list there.

--
Ra*********@gmail.com

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

P: n/a

"Akhenaten" <jo******@gmail.comwrote in message
news:11**********************@36g2000prm.googlegro ups.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($LastPages, __Current_Page__);

and then you can access the previous pages.

Theres probably better ways though....
May 21 '07 #3

P: n/a
Akhenaten <jo******@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.
May 21 '07 #4

P: n/a
On May 21, 1:37 pm, Rami Elomaa <rami.elo...@gmail.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($_SERVER); ?>. It's $_SERVER['...']
something, I don't remember the exact key, but you'll see the complete
list there.

--
Rami.Elo...@gmail.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'];

May 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.