Allen4172 Posted June 15, 2006 Share Posted June 15, 2006 I'm writing an a script where a user can click a link, and it'll bring up an email type prompt where they can email an article link of the story to a friend and so forth.I see it all the time on other sites, but am curious how I would get the <title> or subject of that article dynamically? Any ideas or recomendations would be much appreciated :) Quote Link to comment https://forums.phpfreaks.com/topic/12047-how-to-get-info-from-previous-page/ Share on other sites More sharing options...
phpvolution Posted June 15, 2006 Share Posted June 15, 2006 Hey Mike,just pass the variable with the link:[code]<?php$page = file_get_contents("page.php");preg_match('!<title>(.*?)</title>!is', $page, $match);$title = $match[1];?><a href="emailpage.php?title=<?=$title?>">e-mail this article to a friend</a>[/code]that should do it Quote Link to comment https://forums.phpfreaks.com/topic/12047-how-to-get-info-from-previous-page/#findComment-45805 Share on other sites More sharing options...
Michael4172 Posted June 15, 2006 Share Posted June 15, 2006 [!--quoteo(post=384080:date=Jun 15 2006, 01:07 AM:name=phpvolution)--][div class=\'quotetop\']QUOTE(phpvolution @ Jun 15 2006, 01:07 AM) [snapback]384080[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hey Mike,just pass the variable with the link:[code]<?php$page = file_get_contents("page.php");preg_match('!<title>(.*?)</title>!is', $page, $match);$title = $match[1];?><a href="emailpage.php?title=<?=$title?>">e-mail this article to a friend</a>[/code]that should do it[/quote]Thanks for the info :)However, that begs the question, what if I won't always know the previous page? How would I get that info? As my site is a CMS that has hundreds of possible pages. Quote Link to comment https://forums.phpfreaks.com/topic/12047-how-to-get-info-from-previous-page/#findComment-45838 Share on other sites More sharing options...
Lorian Posted June 15, 2006 Share Posted June 15, 2006 Well if you don't know the previous page, then how to you expect to be able to go to that page and get the contents of the title tag...? Quote Link to comment https://forums.phpfreaks.com/topic/12047-how-to-get-info-from-previous-page/#findComment-45852 Share on other sites More sharing options...
Michael4172 Posted June 15, 2006 Share Posted June 15, 2006 [!--quoteo(post=384127:date=Jun 15 2006, 07:14 AM:name=Lorian)--][div class=\'quotetop\']QUOTE(Lorian @ Jun 15 2006, 07:14 AM) [snapback]384127[/snapback][/div][div class=\'quotemain\'][!--quotec--]Well if you don't know the previous page, then how to you expect to be able to go to that page and get the contents of the title tag...?[/quote]That was my question. I am not wanting to install this manually on every page (doing this manually for hudnreds of pages is not practical). Like I said this is a dynamic type application, which means that I won't know the page. However I am thinking if there is a referrer type variable that I may use. Quote Link to comment https://forums.phpfreaks.com/topic/12047-how-to-get-info-from-previous-page/#findComment-46040 Share on other sites More sharing options...
Michael4172 Posted June 15, 2006 Share Posted June 15, 2006 I found what I was looking for in $_SERVER['HTTP_REFERER'] Quote Link to comment https://forums.phpfreaks.com/topic/12047-how-to-get-info-from-previous-page/#findComment-46082 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.