Jump to content

Session permissions


wtfsmd

Recommended Posts

Hey guys, im trying to figure out why i can't get this to work  :-\

i cut out most of the code, this is just the stuff i thought would be important.

[code]<?php
//start session
session_start();
//include the database login
require 'login/db_connect.php';


//make a connection to the database
$sql = "SELECT username, password, userrank FROM users WHERE username = '".$_POST['uname']."'";

$result = mysql_query($sql) or die(mysql_error());

$row = mysql_fetch_array($result) or die(mysql_error());

// where $row is the record pulled from the database.
$_SESSION['level'] = $row['userrank'];

?>[/code]

on the page that i want admin privileges on i have this(session_start and database connect are cut out but at the top of everything):
[code]<?php
                 

include('fetchnews.php');
print_r($_SESSION);
//session user id
if($_SESSION['level'] == "2") {
include('test.php');


} else {

}

?>[/code]

I have print_r($_SESSION);, and what i get is this:
[code]Array ( [username] => Admin [password] => d159167596fd8ac07a8c9cf92150848d [level] => )[/code]

Here is a screenshot of my database [url=http://tinypic.com/2z7mkie.png]http://tinypic.com/2z7mkie.png[/url]

Any help would be appreciated, i most likely did this wrong lol.
Link to comment
https://forums.phpfreaks.com/topic/34210-session-permissions/
Share on other sites

ah sorry got a little ahead of myself, here is what i need help with:  I am trying to make the session get the userrank for whom ever is logged in, regular people have the rank of 1 admins have the rank of 2. currently my userrank Session is not working most likely because of a error.
Link to comment
https://forums.phpfreaks.com/topic/34210-session-permissions/#findComment-160941
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.