Jump to content

[SOLVED] Pass entire URL into another script


jarvis

Recommended Posts

Hi all,

 

I can't believe how awkward this is. I've a send to friend link on a page:

echo '<a href="send_to_friend.php" onClick="return popup(this, \'send_to_friend\')"
><img src="images/envelope.jpg" width="30" height="30" alt="send to friend" border="0"/></a>';

This then opens up a new window with a simple form - your name, friends name and email and comments.

What I want to do is add the original page URL into the email.

 

This is a dynamic site so the url could be www.mydomain.com/article.php?id=7

 

So I've added the above to my article.php page. All I need to do is pass the effectively dynamic URL through to the send_to_friend.php script.

I've tried:

$ref = getenv("HTTP_REFERER");

$referer = $_SERVER['HTTP_REFERER'];

$ref=@$HTTP_REFERER;

To no avail

 

Any help much appreciated!

you should be able to generate what ur after wiv this :)

 

$pagename  = $_SERVER["SCRIPT_NAME"];

$pagename  = substr($pagename,strrpos($pagename,'/'),strlen($pagename));

$pagename  = str_replace("/", "", $pagename);

 

in order to pull out the dynamic content ur script must allready be pulling from a variable which u could tag onto the end of your href like this :

 

<a href='$pagename?var=$dynamic_var'></a>

 

hope this helps :)

Thanks scooby545 although I don't thin that would do what I'm after!

 

Effectively, I'm on a page such as www.mydomain.com/article.php?id=7 or www.mydomain.com/article.php?id=77

 

This is a single script - article.php which calls in the relevant info depending on the id. On that page is a link, say send to friend:

echo '<a href="send_to_friend.php" onClick="return popup(this, \'send_to_friend\')">Send to friend</a>';

If they click the link, a pop up window opens which is now running send_to_friend.php. What I need to do, is pass www.mydomain.com/article.php?id=7 or www.mydomain.com/article.php?id=77 to that script and include it in the email.

 

Hope that makes a bit more sense?

 

Thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.