Solved

Authentication for multiple user type in php

Posted on 2004-10-13
4
228 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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This article discusses how to create an extensible mechanism for linked drop downs.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now