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
https://forums.phpfreaks.com/topic/60978-user-permissions/
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
https://forums.phpfreaks.com/topic/60978-user-permissions/#findComment-303423
Share on other sites

Archived

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

×
×
  • 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.