Jump to content

Referer?


Muncey

Recommended Posts

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.

Link to comment
Share on other sites

... 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
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.