Very simple back & home links ( Referer )

/ Published in: PHP
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  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


RSS Icon Subscribe to comments

You need to login to post a comment.