jubba890 Posted November 29, 2013 Share Posted November 29, 2013 So I have this code in my members only page. <?PHP //### Start the session session_start(); //### If the user is not logged in, then we re-direct them to log in if(!isset($_SESSION['inzernet_user'])) { header('Location: /login.php'); exit; } //### Check if the user wants to log out if(isset($_GET['action']) && $_GET['action'] == 'logout') { session_destroy(); session_start(); header('Location: /login.php'); exit; } //### Include database connection file include('functions/m_connect.php'); //### Select user information from database $selectUserQuery = "SELECT `username` FROM `user_accounts` WHERE `id` = '{$_SESSION['inzernet_user']}'"; $selectUser = mysqli_query($mysqli, $selectUserQuery); //### Assign user data to variable $user = mysqli_fetch_assoc($selectUser); ?> Hello <?PHP echo $user['username'];?>! <a href="?action=logout">Log out?</a> I want it to display the username and password and other fields I tried adding: echo $user['password']; But that did not work. Thanks! Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted November 29, 2013 Share Posted November 29, 2013 Try adding mysqli_error after the query is processed to see if there are errors: http://php.net/mysqli_error Quote Link to comment Share on other sites More sharing options...
Solution aysiu Posted November 29, 2013 Solution Share Posted November 29, 2013 Your select statement is selecting only username and not password. You can modify it so it includes password: $selectUserQuery = "SELECT `password`, `username` FROM `user_accounts` WHERE `id` = '{$_SESSION['inzernet_user']}'"; Quote Link to comment 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.