Posted By

mentaljason on 03/25/11


link simple back home

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Very simple back & home links ( Referer )

 / Published in: PHP

Simple, It gets the referer and if there wasn't a referer it displays just the home link, but when there is a referer it dispays both back and home, I personaly use this on my 404 page.

  1. <?php
  2. $ref = getenv ("HTTP_REFERER");
  3. if (strlen($ref) <= 1) {echo '<a href="../">&gt; Home</a>';}
  4. else {echo '<a href="'.$ref.'">&gt; Back</a> | <a href="../">&gt; Home</a>';}
  5. ?>

Report this snippet  

You need to login to post a comment.