Jump to content


Photo

Making an access level? (Wont work need help)


  • Please log in to reply
6 replies to this topic

#1 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 12 August 2006 - 09:20 PM

Ok well l have this code:

<?php
session_start();
// Has the user logged in?
	if(!isset($_SESSION['username'])){
		echo 'You are not logged in!';
		// Quit the code so they can't view anything else!
		exit;
	}
	
	$accessLevel = $_SESSION['alevel'];
	
	// Does the user have admin previlages?
	if("$accessLevel" !== 9){
	
	echo 'You do not have permission to access the admin control panel!';
	
		}else{
	

Before you ask sessions are working as l have the print_r function on the session to make sure its working and it prints out:

InArray ( [userid] => 8 [username] => dual_alliance [alevel] => 9 )

So l'm not sure why its not working.  Could anyone shed some light on this ?

Thanks,

dual_alliance

#2 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 August 2006 - 09:22 PM

usergroup levels are done in sessions? i thought they were done in bitwise?

#3 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 12 August 2006 - 09:26 PM

Well l'm making a CMS system so l'm going to have like:

9 = Admin
1 = Guest
2 = Validating

etc....

And l have the usergroup as 9 and its being compared to the number 9 so why won't it work ???  And also when they login l have it so all the static MySQL data in the database is made into sessions.

#4 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 12 August 2006 - 09:33 PM

i think you can only do usergroups in bitwise dude

#5 dual_alliance

dual_alliance
  • Members
  • PipPipPip
  • Advanced Member
  • 140 posts
  • LocationNSW, Australia

Posted 12 August 2006 - 09:45 PM

Dude like what are you on?!?  You have just been posting useless coments!

I fixed it myself.  And you dont need bitwise!

I just had to change
!==
to
!=
and now it works.

#6 newb

newb
  • Members
  • PipPipPip
  • Advanced Member
  • 454 posts

Posted 13 August 2006 - 02:25 AM

k asshole was just trying to help, someone told me u can only do them in bitwise so thats why i said that >_>. no need to be a cockfag about it. if it was that easy then next time fuck off and dont post for help.

#7 elhama

elhama
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 13 August 2006 - 04:44 AM

Ok well l have this code:

<?php

if("$accessLevel" !== 9){
	
	echo 'You do not have permission to access the admin control panel!';
	
}else{	


I think you forgot an exit; right after the echo, you could rather try using die("You do not have permission to access the admin control panel!");

Try doing it this way

<?php
if ($accessLevel != 9) {

    die("You do not have access to the admin panel!");

}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users