Current location: Hot Scripts Forums » Programming Languages » PHP » How to get currentl url in addrss bar via php?


How to get currentl url in addrss bar via php?

Reply
  #1 (permalink)  
Old 02-25-07, 09:10 PM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
How to get currentl url in addrss bar via php?

Hi all. could any one show me how i can obtain whatever the url that the user currently has in their address bar at start of page load?
Reply With Quote
  #2 (permalink)  
Old 02-25-07, 09:16 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:


$url 
'http'. ($_SERVER['HTTPS'] ? 's' null) . '://'$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 
Reply With Quote
  #3 (permalink)  
Old 02-25-07, 09:55 PM
method method is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 228
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Nico View Post
PHP Code:



$url 
'http'. ($_SERVER['HTTPS'] ? 's' null) . '://'$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; 
Thanks for your reply. When i run it it gives the same url 2 time. Is there away to output it once. Since i want to use it as veriable and use it in mysql entry to enter it to db.

furthermore how to display url of page that this php is getting called from for example a php page is called from html page using <image "..../script.php" >

Last edited by method; 02-25-07 at 10:23 PM.
Reply With Quote
  #4 (permalink)  
Old 02-26-07, 03:21 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
The code I gave you doesn't output the URL at all. Can you post how you're using it? It gives the URL only once.

As for the embedded scripts, try using $_SERVER['HTTP_REFERER']. This won't work on all browsers, but on most.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX problem with php dynamic url scott2500uk PHP 3 10-28-06 10:33 AM
stupid question? getting allot info from the url bar pieteke PHP 6 05-07-06 10:44 AM
you search a php upload progress bar ? gigi_online General Advertisements 6 02-01-06 12:39 PM
URL Rederecting with PHP? Cyder PHP 1 08-15-05 09:24 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM


All times are GMT -5. The time now is 05:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.