xadmin Posted July 30, 2008 Share Posted July 30, 2008 Okay, I working on a script that through a controller .php processes login,registration,logout, verification ect. the login controller script looks something like this. private function procLogin () { if ($this->pAuth->login($this->pForm)) { $aUserInfo = $this->pAuth->pDatabase->getUserInfo($szUsername); if ($aUserInfo['userlevel'] == 3 || $aUserInfo['userlevel'] == 9) { functions::echoLocate('Log in successful.', 'http://mobile.mysite.com/privileged.php'); } else { functions::echoLocate('Log in successful.', 'http://mobile.mysite.com/berry.php'); } } else { $this->pForm->rememberData(); functions::echoLocate('Log in failed.', 'http://mobile.mysite.com/failed.php'); } } the problem is when I complete the login forum, using my admin account (level 9) or a level 3 test account. in both cases i'm directed to berry.php this is not supposed to happen. does anyone know another way to write the following in a way that works, as I get zero script errors. $aUserInfo = $this->pAuth->pDatabase->getUserInfo($szUsername); if ($aUserInfo['userlevel'] == 3 || $aUserInfo['userlevel'] == 9) Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/ Share on other sites More sharing options...
ShaunO Posted July 31, 2008 Share Posted July 31, 2008 Just after the getUserInfo call, add die($aUserInfo['userlevel']); Just to make sure it is actually getting the correct user level. Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604097 Share on other sites More sharing options...
xadmin Posted July 31, 2008 Author Share Posted July 31, 2008 I'm assuming you meant like this $aUserInfo = $this->pAuth->pDatabase->getUserInfo($szUsername); die($aUserInfo['userlevel']); if ($aUserInfo['userlevel'] === 3 || $aUserInfo['userlevel'] === 9) The result of adding die($aUserInfo['userlevel']); is that I get a blank white screen unpon successful login. Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604108 Share on other sites More sharing options...
ShaunO Posted July 31, 2008 Share Posted July 31, 2008 Yep. Looks like the $aUserInfo['userlevel'] variable isn't getting any data. Best to double check those API calls are correct and you're passing the right data to it ($szUsername) Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604116 Share on other sites More sharing options...
xadmin Posted July 31, 2008 Author Share Posted July 31, 2008 give me an idea? of how? Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604161 Share on other sites More sharing options...
xadmin Posted July 31, 2008 Author Share Posted July 31, 2008 checked my sessions API and this is what is responsible for populatin the active database /** * Adds the specified user to the database as active, and * populates the _userInfo array for use by {@link whoAmI()} * * @access private * @param string $szUsername The user to add as active * @param string $szIP The users IP address * @param string $szUserAgent The user agent string that they signed in with * @return void */ private function _addMember ($szUsername, $szIP, $szUserAgent) { $this->_userInfo = $this->pDatabase->getUserInfo($szUsername); if ($this->_userInfo !== FALSE) { $this->pDatabase->addMember($szUsername, $szIP, $szUserAgent); } } still cant figure out why data being recieved by $aUserInfo['userlevel'] Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604244 Share on other sites More sharing options...
xadmin Posted July 31, 2008 Author Share Posted July 31, 2008 any idea? Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604428 Share on other sites More sharing options...
xadmin Posted July 31, 2008 Author Share Posted July 31, 2008 this is how my api is configured for returning user info /** * Returns an array of information for the current user, * including their username, email and access level. * * @access public * @param string $szUsername The username we need information on * @return mixed An associate array containing the result, (bool) false if nothing is found */ public function getUserInfo ($szUsername) { $q = sprintf("SELECT `username`, `email`, `userlevel`, `registered_on`, `user_last_active`, `verified` FROM `".TBL_PREFIX."users` WHERE username = '%s' LIMIT 1", mysql_real_escape_string($szUsername)); $pResult = mysql_query($q); return (mysql_num_rows($pResult) == 1) ? mysql_fetch_assoc($pResult) : FALSE; } Link to comment https://forums.phpfreaks.com/topic/117441-sessions-issue/#findComment-604495 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.