Jump to content

Session Problem


Irksome

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

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.