Search code examples
phppost-redirect-get

Hide Div From those who visit directly to the page but don't who refer from a exact domain using php


I want to hide a div from direct users but showing the same div to those who come from example.com

eg. example123.com/article.php have below div

<div id="main">Title</div>

(when user click on a hyperlink on example.com

<a href="http://example123.com/article.php">Artile</a>

then show the above div

but when user come directly to example123.com/article.php then don't show the div.

how will I do that using php?


Solution

  • Hi you can use the following code like this.

     <?php if (isset($_SERVER['HTTP_REFERER'])){ ?>
          <div style="width:200px;height:200px;border:1px solid black">
     <?php } ?>