i have a page whose url is like this
http://www.rp.com/category?name=1&cat=blue
this page is infact accessed from a link in previous page..
the problem is if i write this url as it is in browser then this page is access as normal..but i want to restrict it so that if this page is accessed from the previous page only then it is displayed otherwise it should display a message access denied..
secondaly my variables name and cat appear in the url as it is ..how can i make them look like encoded..
restricting page access
Moderator: General Moderators
-
bugthefixer
- Forum Contributor
- Posts: 118
- Joined: Mon Mar 22, 2004 2:35 am
One way:
Code: Select all
<?php
$referrer = $HTTP_REFERER; //this is the name of the page the user came from
if ($referrer != 'yourpagename.php')
{
print "Access Denied";
exit;
}
//rest of page here
?>-
bugthefixer
- Forum Contributor
- Posts: 118
- Joined: Mon Mar 22, 2004 2:35 am
thanks
thanks all of for replying..
i have used sessions in my website but i cant figure out how i use sessions for this purpose
i have used sessions in my website but i cant figure out how i use sessions for this purpose
-
Illusionist
- Forum Regular
- Posts: 903
- Joined: Mon Jan 12, 2004 9:32 pm
on your first page set a session variable:
Then on your other page check that sessino variable:
Atleast thats what i would do!
Code: Select all
$_SESSION['mine'] = "page1";Code: Select all
if($_SESSION['mine'] != "page1"){
echo "Access Denied!"
}else{
//the rest of your page
}