Solved

Authentication for multiple user type in php

Posted on 2004-10-13
4
258 Views
Last Modified: 2012-05-07
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
Comment
Question by:Gianz
4 Comments
 
LVL 5

Accepted Solution

by:
php-webdesign earned 70 total points
ID: 12305900
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
 
LVL 2

Expert Comment

by:hewtluca
ID: 12305955
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question