I have a mp3 player using php script. when they click the link it will play. the problem is when the link is open a new tab it will automatically downloaded the mp3 song. or when they copy the url link. I want to prevent direct access to that page or open new tab. I want is when they open new tab there is an error page.
in my index.php where they click the link it will play.
echo '<li class="active"><a href="play.php?id='.base64_url_encode($item).'&cid='.$today.'"><img src="./images/song.png" alt="" style="width:20;height:20;border:0;" data-method="post"> ' . $filename . '</a></li>'.PHP_EOL;
the play.php?id=Li9tdXNpYy9NdXNpY3MyL05ldyBGb2xkZXIvTmV3IEZvbGRlci9IYW1ib2cgTmcgU2FncHJvIEtyZXctQWxhYWxhIE5hbGFuZyBmdC4gTFVOIChMeXJpY3MpLm1wMw,,
that "play.php?id=" is I want to prevent from opening in new tab or direct access. only mp3 player can interact to play.php?id=.
I tried to create a session but not working, I tried $_SERVER["HTTP_REFERER"] not working too.
I need a code that is constant in index.php and when the code from index.php is not equal to the code in play.php it will got an error. I tried a time stamp the problem is when it cannot equal the time stamp to the index and to the play.php. any idea? I need a validator from index.php to another page play.php. thanks in advance!
I tried this code for hiding the real url of play.php the problem is the mp3 file will load instead of playing to the player
<a href="index.php" onclick="javascript:$('#myDiv').load('play.php?id=');return false;">Link</a>
<div id="myDiv"></div>