I am running to a problem. When i call this script from my login.php I am sent to the user_main page. I am loggin in with a user that has an accessLevel of highschool but i am not taken to that page. Does anyone have any ideas?
function set_user() {
$_SESSION['user'] = $this->user;
$_SESSION['pw'] = $this->user_pw;
if (isset($_SESSION['referer']) && $_SESSION['referer'] != "") {
$next_page = $_SESSION['referer'];
unset($_SESSION['referer']);
}
// table name is " users " the field with the value of collegiate or highschool is in the field " accessLevel "
$query = sprintf("SELECT accessLevel FROM users WHERE login = '%s' AND pw = '%s'", $this->user, $this->pass);
// Perform Query
$result = mysql_query($query);
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die($message);
}
// Use result
// Attempting to print $result won't allow access to information in the resource
// One of the mysql result functions must be used
// See also mysql_result(), mysql_fetch_array(), mysql_fetch_row(), etc.
while ($row = mysql_fetch_assoc($result)) {
$value = $row['accessLevel'];
}
if (isset($_SESSION['highschool']) && $_SESSION['highschool'] == $value) {
$next_page = $this->high_page;
header("Location: ".$next_page);
}
else if (isset($_SESSION['collegiate']) && $_SESSION['collegiate'] == $value) {
$next_page = $this->coll_page;
header("Location: ".$next_page);
}
else {
$next_page = $this->main_page;
}
header("Location: ".$next_page);
}
function Access_user() {
// connects to dba
$this->connect_db();
// login reader number of times
$this->login_reader();
// login page is set to login.php
$this->login_page = LOGIN_PAGE;
// main page is set to example.php
$this->main_page = START_PAGE;
// main page is set to user_high.php
$this->high_page = HIGH_PAGE;
// main page is set to user_coll.php
$this->coll_page = COLL_PAGE;
// password page resets password by using activate_password.php
$this->password_page = ACTIVE_PASS_PAGE;
}