Page 1 of 1

How to restrict acess to a page if typed in adressBar

Posted: Thu Apr 24, 2008 8:45 pm
by Jakei
Hi I'm a newbie,

My websites has privileges;
When your logged in, privilege=5 and the link "textArea" appears on every htmlPage;
When u click on textArea, you have access to my textArea page that does not exists if you're not logged in which means privilege=0 .
My problem is, I dont want anyone who hasnt logged in to have access to this particular page if privilege=0. example:

localhost/myWebsiteFolder/index.php?idChoice=textArea

-----------------this is my code now I really dont know if I'm on the right path
//define('ID_CHOICE',fct_SESSION('idChoice',"home")); which is in my variableInit.php file;

//this instruction is in another php file.
if (PRIVILEGE == 0)
{
$searchThis=array('idChoice'=> 'editeur');
if (array_key_exists('idChoice',$searchThis)){
echo "-------------------I'm trying to hijack you-------------";

$_SESSION['idChoice] = 'login';
}

$lienLogin = array('idChoice' => 'login');
echo fct_lien ( $lienLogin, 'login');
}else{

$lienLogin = array('idChoice' => 'logout');
echo fct_lien ( $lienLogin, 'logout');

}

please help !
Jakei

Re: How to restrict acess to a page if typed in adressBar

Posted: Fri Apr 25, 2008 1:42 am
by Kieran Huggins
I have to say, I think I read your post 3 times and I'm still not sure what you're trying to accomplish.

Can you give us a specific use case?

Re: How to restrict acess to a page if typed in adressBar

Posted: Sat Apr 26, 2008 4:53 am
by Chris Corbyn

Code: Select all

<?php
 
if (PRIVILEGE != 5) {
  exit('Access denied');
}
Not very elegant, but easy for a "newbie" to understand :)