Jump to content

Recommended Posts

Hi all,

 

I'm in the process of making a user management script, and have come to a dead end here.

 

I have the following code for the page that lists the current user accounts registered in the database.

 

<?php
session_start();

require "../db.php";
require "../global.php";

  switch ($_SESSION['user_level']) {
default:echo $text['adminperms']; exit;
    	case 4:
case 5:

$result = mysql_query("SELECT * FROM com_users WHERE user_level > 4 ORDER BY userid DESC",$connection) or die(mysql_error());
$user_list = "<ul>";
while ($myrow = mysql_fetch_assoc($result)) {
$userid = $myrow['userid'];
$username = $row['lname'];
$user_level = $row['fname'];
$user_list .= "<li><a href=\"edit_user.php?userid=$userid\">$username</a>";
}
$user_list .= "</ul>";

}

?>

 

The problem is, I'm getting logged out whenever this page is accessed, therefore getting my "No admin permissions" error message. I've tried running this script without the permission requirements, but still no joy, just a blank page.

 

If anyone could point out what's wrong with that code then I would be ever so grateful.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/70124-session-problem/
Share on other sites

  switch ($_SESSION['user_level']) {
default:echo $text['adminperms']; exit;
    	case 4:
case 5:

 

should be:

 

  switch ($_SESSION['user_level']) {
default: echo $text['adminperms']; exit; break;
    	case 4: /* do something */ break;
case 5: /* do something */ break;
}

 

Every case has to break at the end.

Link to comment
https://forums.phpfreaks.com/topic/70124-session-problem/#findComment-352181
Share on other sites

$result = mysql_query("SELECT * FROM com_users WHERE user_level > 4 ORDER BY userid DESC",$connection) or die(mysql_error());
echo"<ul>";
while ($myrow = mysql_fetch_assoc($result)) {
$userid = $myrow['userid'];
$username = $row['lname'];
$user_level = $row['fname'];
echo"<li><a href=\"edit_user.php?userid=$userid\">$username</a>";
}
echo"</ul>";

Link to comment
https://forums.phpfreaks.com/topic/70124-session-problem/#findComment-352368
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.