Skip to content

Instantly share code, notes, and snippets.

@mikeoberdick
Last active February 29, 2024 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeoberdick/db99f7da4414b48b61271e19bf13ce6d to your computer and use it in GitHub Desktop.
Save mikeoberdick/db99f7da4414b48b61271e19bf13ce6d to your computer and use it in GitHub Desktop.
Create a button to go back to the previous page with referrer checks
<?php $referrer = $_SERVER['HTTP_REFERER']; ?>
<?php if (str_contains($referrer, 'simplify-the-market-blog')) {
$href = "javascript:history.back()";
else {
$href = "/simplify-the-market-blog";
} ?>
<a href="<?php echo $href; ?>" class="btn"><i class="la la-angle-left"></i> Back</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment