Prevent Direct Url Access in PHP

Add the below piece of code to header file of your application and prevent direct URL access . Any user who tries to navigate via changing the URL or post data will be redirected to previous webpage.

1
2
3
4
< ?php
if(!isset($_SERVER['HTTP_REFERER']))
{     echo '<script>history.back();'   }
?>