I'm doing a project where I'm supposed to create a website that people can register and log in. I'm trying to do that thing where it will say in the corner "Logged in as ..."
This is part of the code that assigns the variable name to the name value in the database when the user logs in.
$first = mysql_query("SELECT FirstName FROM students WHERE studentID = '$user' AND password = '$pass'");
$firstname = mysql_fetch_array($first);
$_SESSION['name'] = $firstname;
And this is the code on the website that displays the name
<?php
if(isset($_SESSION['name']))
{
echo '<li class="disabled"><a href="#" disabled>Signed in as ' . $_SESSION['name'] . '</a></li>';
}
?>
But when the website is actually ran the space is left blank. I know the variable is set because I replaced $_SESSION['name'] with some random string and it echo'd it fine. I also ran the SQL query and it gave me back the name. What am I missing from my code?