Jump to content

User Permissions


Irksome

Recommended Posts

Hi all,

 

I'm making a website with an admin section, and one facet of that is user management.

 

I've made a script for this task, but I want it to be accessable only to people with user level 4 or 5.

 

Here's the code for the script. At present, it isn't accessable to anybody, even level 4 and 5 users.

 

<?php

require '../db.php';
require '../global.php';

  switch ($_SESSION['user_level']) {
    case 5:echo 

        $result = mysql_query("SELECT * FROM com_users ORDER BY userid DESC",$connection)or die(mysql_error());

        while($myrow = mysql_fetch_assoc($result))

             {//begin of loop

               //now print the results:

               echo $myrow['username'];

               echo "<a href=\"edit_user.php?userid=$myrow[userid]\">Edit User</a>";

               echo '<br>';

             }//end of loop

;
    case 0:echo $text['adminperms'];exit;
    case 1:echo $text['adminperms'];exit;
    case 2:echo $text['adminperms'];exit;
    case 3:echo $text['adminperms'];exit;
}

?>

 

Could anyone point me in the right direction here?

 

Thanks.

Link to comment
Share on other sites

I just do this in the login script:

 

$r=mysql_fetch_array(mysql_query("SELECT * FROM member WHERE Username='$username' && Password='$password' LIMIT 1;"));
if ($r['permissions']>=4){
      $_SESSION['admin']='y';
}

 

then on each admin page:

 

if($_SESSION['admin']!='y'){
$go='http://www.url_goes_here.com';
header('Location: '.$go);
}

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.