Get last page visited

混江龙づ霸主 提交于 2019-11-30 14:28:13

The HTTP referer header is the only way. This is the data that is given to you in PHP via $_SERVER['HTTP_REFERER'].

Note that this header will work in most cases. Also note that it can be easily spoofed.

Why not add a GET variable to the link on youtube - www.yoursite.com/?referrer=youtube

For discretion and appearance you could rewrite the URL to something like www.yoursite.com/youtube

<?php 
    if (strpos($_SERVER['HTTP_REFERER'],'youtube') !== false){
        echo 'Welcome! You already know how it works, <a href="/register">register now!</a>';
    } else {
        echo 'Welcome! Please watch our video first at <a href="www.youtube.com/myvideo">www.youtube.com/myvideo</a>';
}?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!