How to display a BACK button but ONLY if the user came from somewhere else on my site I'd like to display a BACK button on my node--resource.tpl.php file but ONLY if the user came to the node from another part of my site. If they copied and pasted the URL for the node directly into their browser's address bar and got to it that way I do NOT want the button to appear.

Here' the button in my tpl:

&lt;input type="button" value="Go Back" onclick="history.go(-1)" /&gt;


Anyone know how to do this with PHP (or another Drupal method)?
There are many ways to do this.
One of it would be to use $_SERVER['HTTP_REFERER'] to detect where the user comes from.

Put the following code in your template file. 

if (strstr($_SERVER['HTTP_REFERER'], 'facebook.com') !== false) {
     // Facebook brought me to this page.
     print '&lt;a href="javascript: history.go(-1)"&gt;Go Back&lt;/a&gt;';  }