Jump to content

PHP echo SQL query


jubba890
Go to solution Solved by aysiu,

Recommended Posts

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!

Link to comment
Share on other sites

  • Solution

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']}'";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.