php / mysql - Issue when redirecting based on user_level -
i'm building control panel based on user_level. if user has level (0) can't access besides index page, level (1) can access everything.
my problem is, current code using... redirects me index page, if set user_level above 0.
code:
<?php $db_connection = new mysqli(db_host, db_user, db_pass, db_name); require_once("config/db.php"); $page_rows = results_per_page; if (!$db_connection->set_charset("utf8")) { $db_connection->errors[] = $db_connection->error; } if($_session["user_level"] == 0) { header('location: index.php'); } ?>
and if try using following code....
<?php $db_connection = new mysqli(db_host, db_user, db_pass, db_name); require_once("config/db.php"); $page_rows = results_per_page; if (!$db_connection->set_charset("utf8")) { $db_connection->errors[] = $db_connection->error; } if($_session["user_level"] == 0) { header('location: index.php'); } else { header('location: download.php'); ?>
i http error 500 on download.php page.
all appreciated. (sorry 'noob' mistakes, first bigger project).
you using session
like:
if($_session["user_level"] == 0) { header('location: index.php'); }
but session not started here. start session on first line like:
session_start();
only after can access session variable.
Comments
Post a Comment