开发者

PHP: check from which page the link is directed

lets say i have a page hit.php in my website and the link is to this page is available on every\many pages in the website..

lets say i click <a href"hit.php">HIT</a> from any page.....

is there a way when hit.php is loaded i could know that the page from which this page was..

meaning if i click the link to hit.php from 'index.php开发者_JS百科' i could check loading hit.php that the user is navigating here from 'index.php' or any other page...

i know this i could establish in site by passing variables in URL like 'hit.php?pagename=index' but is there another way

p.s i know its crazy but still :)


$_SERVER['HTTP_REFERER'], although it can easily be spoofed or disabled.


You can use the referer. In PHP, it's:

$_SERVER['HTTP_REFERER']

However, users can configure their browsers not to send this, or spoof it. You should ensure that your code doesn't break if it's absent, or faked.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜