469,632 Members | 1,750 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,632 developers. It's quick & easy.

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

May 21 '07 #1
4 8570
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

"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
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
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.

Similar topics

1 post views Thread by Jonathan | last post: by
1 post views Thread by jadamson60 | last post: by
1 post views Thread by Tony Zoccolillo | last post: by
reply views Thread by Sergey | last post: by
2 posts views Thread by Dan | last post: by
1 post views Thread by Techhead | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.