runnerjp Posted November 25, 2007 Author Share Posted November 25, 2007 ok what i got now is on profile.php echo 'Hello <em><b><u>' . get_username ( $_SESSION['user_id'] ) . '</u></b></em>!<br />this is your name.<br /><br />'; echo 'email <em><b><u>' . get_email ( $_SESSION['user_id'] ) . '</u></b></em>!<br />is your email.<br /><br />'; i used the id i had from other post to make this work and sessions looks like this // ------------------------------------------------------------------------ /** * Get username - Returns the username of the logged in member based on session ID * * @access public * @param string * @return string/bool */ function get_username ( $id ) { global $db; $query = "SELECT `Username` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id ); if ( $db->RecordCount ( $query ) == 1 ) { $row = $db->getRow ( $query ); return $row->Username; } else { return FALSE; } } /** * Get email- Returns the email of the logged in member based on session ID * * @access public * @param string * @return string/bool */ function get_email ( $id ) { global $db; $query = "SELECT `Email` FROM `" . DBPREFIX . "users` WHERE `ID` = " . $db->qstr ( $id ); if ( $db->RecordCount ( $query ) == 1 ) { $row = $db->getRow ( $query ); return $row->Email; } else { return FALSE; } } it works great obviusly when a user is logged in BUT when they are not then how can i show the users data? Quote Link to comment https://forums.phpfreaks.com/topic/78700-creating-profile/page/2/#findComment-398945 Share on other sites More sharing options...
runnerjp Posted November 25, 2007 Author Share Posted November 25, 2007 simple feature but it only works if a user is logged in... how can i edit the code so it gets it also for users who arnt logged in? maybe having a link to go through where it will send the id so the function can get the user id and still use it Quote Link to comment https://forums.phpfreaks.com/topic/78700-creating-profile/page/2/#findComment-398975 Share on other sites More sharing options...
runnerjp Posted November 25, 2007 Author Share Posted November 25, 2007 *bumping* Quote Link to comment https://forums.phpfreaks.com/topic/78700-creating-profile/page/2/#findComment-399061 Share on other sites More sharing options...
runnerjp Posted November 26, 2007 Author Share Posted November 26, 2007 bump Quote Link to comment https://forums.phpfreaks.com/topic/78700-creating-profile/page/2/#findComment-399319 Share on other sites More sharing options...
trq Posted November 26, 2007 Share Posted November 26, 2007 All you need do is pass your functions an id. How you get this id is up to you. In the link to the example I orginally posted, there is a small script that lists all users as links to the profile.php page. That should get you a good start. Quote Link to comment https://forums.phpfreaks.com/topic/78700-creating-profile/page/2/#findComment-399342 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.