jarvis Posted August 7, 2009 Share Posted August 7, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/169225-solved-pass-entire-url-into-another-script/ Share on other sites More sharing options...
scooby545 Posted August 7, 2009 Share Posted August 7, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/169225-solved-pass-entire-url-into-another-script/#findComment-892904 Share on other sites More sharing options...
jarvis Posted August 7, 2009 Author Share Posted August 7, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/169225-solved-pass-entire-url-into-another-script/#findComment-892924 Share on other sites More sharing options...
elis Posted August 7, 2009 Share Posted August 7, 2009 Couldn't you use $_SERVER['HTTP_REFERER']; in your send_to_friend script, which would show the url the user clicked on to reach Send to Friend? Quote Link to comment https://forums.phpfreaks.com/topic/169225-solved-pass-entire-url-into-another-script/#findComment-892933 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.