473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 8719
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Jonathan | last post by:
Is there a way that I can determine the current url/location (like the 'location' variable in javascript)? For example, if I'm at http://mysite.com/index.php, is there perhaps a fixed variable...
3
by: deko | last post by:
I use #currentlink in a nav list of links to indicate which page is currently being viewed. The code in the nav list looks like this: <p><a href="index.php">Home Page</a></p> <p><a...
4
by: Penny | last post by:
Hi all, How can I retrieve the current page url(and parameters/arguments) using ASP code? The current page is an asp search results page so the url includes the page name and the...
1
by: jadamson60 | last post by:
>From http://developer.irt.org/script/992.htm ============================================= Q992 How can I accept a name/value pair in the current url and access it as a variable and value? ...
1
by: Tony Zoccolillo | last post by:
I have a toolbar aspx page in a frameset. On the toolbar is a dropdownlist. The frameset is launched from an outside source and comes in with a specific parameter for the module desires, like......
0
by: Sergey | last post by:
How can I get current page url? Now I've been using on page something like this: HttpContext.Current.Request.Url.LocalPath but if we get to page with help of Server.Transfer I will get...
2
by: Dan | last post by:
I'm having trouble getting the current page URL into a local string variable. I've tried using the System.Security.Policy.URL.Value but I get the message "Reference to non-shared member requires...
1
by: Techhead | last post by:
How do I capture the current URL to a string? What I want to do is press a "submit" button that takes me to whatever URL is present in the address bar of the browser. Thanks, Brian
1
by: RSH | last post by:
Hi, I have a user created control that has quite a bit of codebehind code. I have one link in the HTML page code that I need to insert the current URL in. I have tried several scenerios but...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.