Displaying current user and id from database in php/mysql?

Jeff S

New member
I'm making a little website for some friends, just messing around trying to learn a little bit of coding as I go. Anyways I have it set up so when you register it saves an ID that auto increments, a username, and an encrypted password.

What I'm trying to do is display that ID and username in text on the side of the page. I've been able to query the database and use echo to display the results, but only for the entire table, not the particular user that may be logged in.

I have sessions in use but only to restrict the page to logged in users only, do I have to do more with sessions to display the id/user?

<?php
//Start session
session_start();
//Check whether the session variable
//SESS_MEMBER_ID is present or not
if(!isset($_SESSION['SESS_MEMBER_ID']) ||
(trim($_SESSION['SESS_MEMBER_ID'])=='')) {
header("location: index.html ");
exit();
}
?>
 
Back
Top