Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 287
  • Last Modified:

Authentication for multiple user type in php

I have a problem on authentication in php. You see, I have three types of account, one for a guest, one for a normal member and another one for an administrator. Now, how can I limit the directories that each type of member account can access? for example, a member will normally gain access to the default.php page. However, he shouldn't be able to access the admin.php page. How do I resolve this?
0
Gianz
Asked:
Gianz
1 Solution
 
php-webdesignCommented:
i gues you put the information in sessions

create a file inc_logged_in_heretheuserlevel(eg admin).php:

<?
if($_SESSION['userlevel'] != "admin"){
  die("Not allowd to enter this page!!");
}
?>

and inlcude this file on every page you only want your admin to enter it. And for user and guest do the same
0
 
hewtlucaCommented:
Yeah php-webdesign is right........put what he says at the top of the pages you want to protect.

Just assign your session variables at the same time they login.......I also assign

$_SESSION['logged']==true

Just make sure you destroy the session when they logout.

Hewt
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now