Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2007, 05:43 PM   PM User | #1
nickyfraggle
Regular Coder

 
Join Date: Mar 2006
Posts: 197
Thanks: 27
Thanked 2 Times in 2 Posts
nickyfraggle is an unknown quantity at this point
get URL using php

Hello,

I'm writing a send to a friend script which sends the URL of a webpage to an email address that the user puts into a form.

I'm having trouble getting the URL of the page if it is something like articles.php?category=news

I can handle simple filenames fine like articles.php works no problem.

PHP Code:
$dirandfile basename($_SERVER['PHP_SELF']);
$domain $_SERVER['SERVER_NAME'];
$url "http://$domain/$dirandfile"
How can I get my script to handle these url's?

Thank you,

Nicola
nickyfraggle is offline   Reply With Quote
Old 07-05-2007, 06:50 PM   PM User | #2
ess
Regular Coder

 
Join Date: Oct 2006
Location: United Kingdom
Posts: 865
Thanks: 7
Thanked 29 Times in 28 Posts
ess will become famous soon enough
Hi Nicola,

try the following

Code:
$_SERVER['REQUEST_URI']
the result should be something like
Code:
/articles.php?category=news
Cheers,
Ess
ess is offline   Reply With Quote
Old 07-05-2007, 07:00 PM   PM User | #3
phpandmysql
New Coder

 
Join Date: Jul 2007
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
phpandmysql is an unknown quantity at this point
Post

This should do it:

PHP Code:
$currentpage $_SERVER['REQUEST_URI'];
$domain $_SERVER['SERVER_NAME']; 
$domain str_replace('www.'''$domain); 
$domain "http://www.$domain";
$fullurl "$domain$currentpage"
you can echo currentpage, domain and fullurl seperately to see each result. I believe you are looking for the fullurl.

Enjoy.
__________________
PHP and MYSQL
$string = "3Ip*hKEpanKI#8dmUys&*KqlIJ*P8D";
$new_string = ereg_replace("[^a-z]", "", $string);
echo "<a href=http://www.$new_string.org>$new_string</a>";
phpandmysql is offline   Reply With Quote
Old 07-07-2007, 10:35 AM   PM User | #4
nickyfraggle
Regular Coder

 
Join Date: Mar 2006
Posts: 197
Thanks: 27
Thanked 2 Times in 2 Posts
nickyfraggle is an unknown quantity at this point
Thank you!!

That's great...

Nicky
nickyfraggle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:47 PM.


Advertisement
Log in to turn off these ads.