Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to get the URL on current page??
Old 08-19-2008, 08:54 PM How to get the URL on current page??
Webmaster Talker

Posts: 626
Trades: 0
I'm trying to run a script that looks for the URL that the user is currently on. The problem that I'm running into is that the page has already been redirected and if I use the $_SERVER['REQUEST_URI'] variable, it will give me the url that was originally typed in. I need to get the url that is actually showing.

How do I do this?
jim.thornton is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-19-2008, 10:48 PM Re: How to get the URL on current page??
Skilled Talker

Posts: 61
Trades: 0
try:

<?PHP
print_r($_SERVER);
?>

then select which of these variables suits your need.
just_a_pod is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 04:05 AM Re: How to get the URL on current page??
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
PHP Code:
$_SERVER["SCRIPT_NAME"]

$_SERVER["PHP_SELF"]

$_SERVER["SCRIPT_FILENAME"
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?

Last edited by chrishirst; 08-20-2008 at 04:09 AM..
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-20-2008, 10:55 AM Re: How to get the URL on current page??
Webmaster Talker

Posts: 626
Trades: 0
Thanks very much! You guys are life savers. I've been messing around with this for 2 days.

The print_r() function really helped. I found a variabel $_SERVER['REDIRECT_URL'] which contained exactly what I was looking for. However, if the page hasn't been redirected then that variable doesn't exist so I had to put some logic in to use $_SERVER['REQUEST_URI'] instead.
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 08-20-2008, 08:08 PM Re: How to get the URL on current page??
Junior Talker

Posts: 2
Trades: 0
remember you can also put in:

phpinfo();

which will give you the list of all page variables. From here you can see which variable matches your requirement.

< link drop removed >
__________________

Please login or register to view this content. Registration is FREE
- Hot girls and guys compete against each other in the ultimate game of hot.

Last edited by chrishirst; 08-21-2008 at 04:36 AM..
larabingle is offline
Reply With Quote
View Public Profile
 
Old 08-22-2008, 05:50 AM Re: How to get the URL on current page??
Skilled Talker

Posts: 85
Name: Ilyes Rhouma
Trades: 0
http://myphpsource.blogspot.com/2008...e-and-url.html
__________________
Want a cheap and custom programmer or writer ?
Please login or register to view this content. Registration is FREE

Are you
Please login or register to view this content. Registration is FREE
? Start
Please login or register to view this content. Registration is FREE
free and earning money !
Please login or register to view this content. Registration is FREE
Ilyes is offline
Reply With Quote
View Public Profile Visit Ilyes's homepage!
 
Reply     « Reply to How to get the URL on current page??
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.34458 seconds with 12 queries