I can't seem to display the information of the user currently logged in. I'm not sure what I'm doing wrong here. I've got my login page and logout function working correctly, and when I register a user it add that user to the database, but I want to be able to display the current users data when they log in.
<?php
session_start();
// connects to the database
$mysqli = new mysqli("localhost", "root", "");
$query = "SELECT firstName, lastName, username, password, loyaltyPoints FROM user WHERE username = '".$_SESSION['username']."'";
if($result = $mysqli->query($query))
{
while($row = $result->fetch_assoc())
{
echo $row['firstName'];
echo $row['lastName'];
echo $row['username'];
echo $row['password'];
echo $row['loyaltyPoints'];
}
$result->free();
}
else
{
echo "No results found";
}
?>
<html>
<head>
</head>
<body>
Welcome! Click here to <a href="logout.php" tite="Logout">Logout.</a>
or here to go to the home page --> <a href ="INDEX.html">HOME</a>
</body>
</html>