Jul 18 2008
Using PHP for Convenient Linking
Since I’ve been learning more about PHP I decided to discuss one way I use it to help provide readers the code to link to a page they may feel is worthy of a link. With just a small snippet of PHP the code, linking code will update to link to the previous page or post the reader was reading. There has been a couple times I came across pages and debated whether or not to link out to it. If the website had a convenient “link to us” page for the specific page I was reading, im may of went ahead and placed the resource on my website. People are busy, lazy and sometimes just lacking the motivation to link out to you even if your page is a great resource. Convenience may be the one thing that can initiate a great back link.
Lets say you place the below code on yoursite.com/linktous.php. Each time its clicked to from any other page only the page its clicked from will appear as the url in the a href portion of the linking code.
An example of this is shown near the top of this page.
<textarea style=”height:68px;width:100%;”>
<a href=”<? echo $_SERVER['HTTP_REFERER']; ?>”>
example.com</a></textarea>
The process spelled out.
1. Drunk blogger finds a great story about that time you drank that pony keg >>
2. Reader likes your story >>
3. Reader clicks on “link to this page” link, on the menu bar. >>
4. A page opens up with the code needed to link to that specific page for the reader to copy and paste into his site.
5. Reader finds another page about drinking games.
6. Reader once again clicks on “link to this page”.
7. Same page opens, only this time with the code needed to link to this specific page.
This is where I’m at for right now, I’ll soon come up with another snippet of code to help create and input specific anchor text into the linking code which will better relate to the referrer page instead of just using the domain name.




