Jump to content

PHP echo SQL query


jubba890

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
https://forums.phpfreaks.com/topic/284373-php-echo-sql-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.