Jump to content

Making an access level? (Wont work need help)


dual_alliance

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.