I am trying to create a link that passes the complete, current URL including server queries to a new page. The purpose is that someone can complete a form to mail the URL to a friend. Therefore I need to capture the URL and embed it in the mail message.
I am having problems with the link being displayed in the new page. All the following works as intentded....
--
$url .= ".."; // sets path back to root
$url .= $PHP_SELF."?".$_SERVER['QUERY_STRING']; // grabs whole current URL
if ($mail) {
print "<a href=\"?p=tell_a_friend&url=$url\" target=_blank>e-mail</a>"; // prints a link to the mail page
}
--
Note, 'p' is the name of the 'page' to include in my template.
The variable 'mail' in my example URL turns this link on for development purposes on the server. There is a link to 'e-mail' right at the bottom of the page.
On the new page, the URL is only diplayed as far as the first query. You can see it here...
http://www.gravity-slaves.co.uk/main/?p=show_article&article_ID=136&mail=yes
becomes
http://www.gravity-slaves.co.uk/main/?p=show_article
and the $article_ID is dropped!
Obviously the URL is 'escaping' at the first '&'. How could I stop this?
I can't just reference the article_ID as well since I would like this link to work site wide.
Any clues?
TIA.