pcjackson06 Posted March 29, 2009 Share Posted March 29, 2009 OK, I added a new $_SESSION variable below ... but when I do <?php echo $_SESSION['r_id']; ?> it doesn't work like with userId. Any ideas? It's driving me NUTS. <?php include_once('includes/global.php'); session_start(); /***************************************************************************** Description: The access point for the application. *****************************************************************************/ $err = array(); if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) { // first check if the number submitted is correct $number = $_POST['txtNumber']; if (md5($number) == $_SESSION['image_random_value']) { // set to includes directory for iris include_once('includes/opendb.php'); $userId = $_POST['txtUserId']; $password = $_POST['txtPassword']; // check if the user id and password combination exist $sql = "SELECT u.user_id AS user_id, u.isactive, al.name AS access_level , u.r_id AS r_id FROM tbl_auth_user u, tbl_access_level al WHERE u.user_id = '$userId' AND u.access_level_id = al.id AND u.user_password = MD5('$password')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); if (mysql_num_rows($result) == 1) { $row = mysql_fetch_array($result); // the user id and password match, // set the session $_SESSION['image_is_logged_in'] = true; ini_set('session.cookie_lifetime', (14400000)); // remove the random value from session $_SESSION['image_random_value'] = ''; $_SESSION['ris_user'] = $userId; $_SESSION['ris_id'] = $r_id; $_SESSION['ris_al'] = MD5($row['access_level']); if ($row['isactive'] == 1) { // after login we move to the main page - set this to your main page location header('Location: home.php'); exit; } else { array_push($err, "Error: Invalid User."); } } else { array_push($err, "Error: Username or password is incorrect."); } include_once('includes/closedb.php'); } else { array_push($err, "Error: Incorrect number."); } } ?> Link to comment https://forums.phpfreaks.com/topic/151580-session-variables-driving-me-nuts/ Share on other sites More sharing options...
pcjackson06 Posted March 29, 2009 Author Share Posted March 29, 2009 I figured this out - forgot to wrap it with the ($row()). Link to comment https://forums.phpfreaks.com/topic/151580-session-variables-driving-me-nuts/#findComment-796107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.