Jump to content

Archived

This topic is now archived and is closed to further replies.

dual_alliance

Making an access level? (Wont work need help)

Recommended Posts

Ok well l have this code:

[code=php:0]<?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{

[/code]

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

Share this post


Link to post
Share on other sites
usergroup levels are done in sessions? i thought they were done in bitwise?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
i think you can only do usergroups in bitwise dude

Share this post


Link to post
Share on other sites
Dude like what are you on?!?  You have just been posting useless coments!

I fixed it myself.  And you [b]dont[/b] need bitwise!

I just had to change [code=php:0]!==[/code] to [code=php:0]!=[/code] and now it works.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote author=dual_alliance link=topic=104023.msg414722#msg414722 date=1155417631]
Ok well l have this code:

[code=php:0]<?php

if("$accessLevel" !== 9){

echo 'You do not have permission to access the admin control panel!';

}else{
[/code]
[/quote]

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

[code=php:0]
<?php
if ($accessLevel != 9) {

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

}
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.