SunQuest
           PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 24th, 2004, 01:03 AM
c0rbin c0rbin is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Houston, TX, USA
Posts: 8 c0rbin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to c0rbin
Grabbing the current URL as a variable

So I can use it in some script.

Is there a method for grabbing the current URL.

I am building on a "Tell a Friend" script and it currently has me "hard code" typing in the root of the site. I would like for my users to pass on a specific page.

Can PHP grab the current URL and set is as a variable so I can use it as described above?

Reply With Quote
  #2  
Old January 24th, 2004, 01:06 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: Grabbing the current URL as a variable

php Code:
Original - php Code
  1.  
  2. $hostname = $_SERVER["HTTP_HOST"];
  3. $filename = $_SERVER["REQUEST_URI"];
  4. $referer  = $_SERVER["HTTP_REFERER"];
  5. /* Print current URL */
  6. print "http://$hostname/$filename";
  7. print "<br>";
  8. /* Print Last URL (Referer) */
  9. print $referer;
  10. ?>

value of old threads... http://codewalkers.com/forum/index.php?action=displaythread&forum=phpcoding&id=1805&realm=default

Reply With Quote
  #3  
Old May 15th, 2008, 01:54 PM
_Chris_ _Chris_ is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 4 _Chris_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 46 sec
Reputation Power: 0
Been trying desperately to create a form like this for some time, but clicking on that link above gives me a 404 ?

Chris.

Reply With Quote
  #4  
Old May 16th, 2008, 02:45 AM
DavidMR's Avatar
DavidMR DavidMR is online now
Contributing User
Click here for more information.
 
Join Date: Apr 2007
Location: Ireland
Posts: 711 DavidMR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Week 4 Days 13 h 52 m 42 sec
Reputation Power: 2
PHP Code:
<?php
function GetCurrentPage() {
 
$CurPageURL 'http';
 if (
$_SERVER["HTTPS"] == "on") {$CurPageURL .= "s";}
 
$CurPageURL .= "://";
 if (
$_SERVER["SERVER_PORT"] != "80") {
  
$CurPageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
  
$CurPageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return 
$CurPageURL;
}
?>


declare that in an include file or anywhere and call using:

PHP Code:
echo GetCurrentPage(); 


or

PHP Code:
 $your_variable GetCurrentPage(); 
__________________
When I die, I want to go peacefully like my Grandfather did, in his sleep -- not screaming, like the passengers in his car.

Reply With Quote
  #5  
Old May 17th, 2008, 03:06 AM
mojtaba_g79's Avatar
mojtaba_g79 mojtaba_g79 is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 43 mojtaba_g79 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 45 m 29 sec
Reputation Power: 2
As other friends said, you can get many information using $_SERVER variable.
try this code and use any variable you need:
Code:
<?php
echo "<hr><pre>";
print_r($_SERVER);
echo "</pre><hr>";
?>

Reply With Quote
  #6  
Old May 17th, 2008, 03:15 AM
_Chris_ _Chris_ is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 4 _Chris_ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 12 m 46 sec
Reputation Power: 0
Thumbs up

Many, many thanks, it's very much appreciated.

Chris.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Grabbing the current URL as a variable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway