Muncey Posted May 19, 2007 Share Posted May 19, 2007 I want to make something so that you can only see a page if you have been referred there by a certain page. For example www.bla.com/test.php can only be accessed if the page it was linked from was www.bla.com/test123.php. How would i go about doing this? You don't have to litrally write the code out if you don't want to, just an idea of what i have to learn/read in order to do this (i know basic php, been doing it for a while but ive had a big break so i don't remember much). Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/52076-referer/ Share on other sites More sharing options...
hitman6003 Posted May 19, 2007 Share Posted May 19, 2007 $_SERVER['HTTP_REFERER'] http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server Quote Link to comment https://forums.phpfreaks.com/topic/52076-referer/#findComment-256758 Share on other sites More sharing options...
john010117 Posted May 19, 2007 Share Posted May 19, 2007 ... but it's not reliable, as stated in the manual. Try using sessions instead. First page: <?php session_start(); $_SESSION['page_refer'] = $_SERVER['PHP_SELF']; ?> Second page: <?php session_start(); if(!isset($_SESSION['page_refer'])) { return false; } else { //continue with your code } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52076-referer/#findComment-256795 Share on other sites More sharing options...
PC Nerd Posted May 19, 2007 Share Posted May 19, 2007 what i do is logg every page a user visits. simply adding their user ID, time, and IP, and pagename to the database. so what might be an idea, is to simply add code ( include?) at the begining of each page, that stats its name, eg $Session['pg_referer'] = "Thing.php"; then you can simply test that variabel to equal your page. gdlk Quote Link to comment https://forums.phpfreaks.com/topic/52076-referer/#findComment-256805 Share on other sites More sharing options...
Muncey Posted May 19, 2007 Author Share Posted May 19, 2007 Thanks a lot i will test all these and choose the best one. Again thanks all that replied. Quote Link to comment https://forums.phpfreaks.com/topic/52076-referer/#findComment-257245 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.