Hi all,

I've got the following script which is a login form which checks for entries in a mysql database.

Once the user has successfully logged in, it displays their username and password. (session_register etc)

I can display the username and password, but I cant get it to display the firstname column entry in the database. Is there something I'm doing wrong?

Here's the code:
PHP Code:
<?
session_start
();

if (
$user && $pass)
{
  
// if the user has just tried to log in

  
$db_conn mysql_connect("localhost""root""");
  
mysql_select_db("mdgal"$db_conn);
  
$query "select user, pass, firstname from users WHERE user='$user' and pass='$pass'";
  
$result mysql_query($query$db_conn);
  if (
mysql_num_rows($result) >)
  {
    
// if they are in the database register the user id
    
$valid_user $user;
    
session_register("valid_user");
    
    
$valid_pass $pass;
    
session_register("valid_pass");
    
    
$valid_firstname $firstname;
    
session_register("valid_firstname");

  }
}
?>

<html>
<head>
<title>MdGal - (Template)</title>

</head>

<body leftmargin="0" topmargin="0">
<table width="100%" height ="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="85"><?php include("includes/header.php"); ?></td>
  </tr>
  <tr>
    <td height="*" valign="top">
    <!-- Begin of  main content area  -->
    <table width="100%" height ="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="150" valign="top"><?php include("includes/side_nav.php"); ?></td>
    
          <td width="*" valign="top">&nbsp;



<? 

  
if (session_is_registered("valid_user"))
  {
    echo 
"Your username is: $valid_user <br>";
    echo 
"Your password is: $valid_pass <br>";
    echo 
"Your firstname is: $valid_firstname <br>";
    
    
    echo 
"<a href=\"logout.php\">Log out</a><br>";
  }
  else
  {
    if (isset(
$user))
    {
 
      echo 
"Could not log you in";
    }
    else 
    {

      echo 
"You are not logged in.<br>";
    }

    
// provide form to log in 
    
echo "<form method=post action=\"login.php\">";
    echo 
"<table>";
    echo 
"<tr><td>Userid:</td>";
    echo 
"<td><input type=text name=user></td></tr>";
    echo 
"<tr><td>Password:</td>";
    echo 
"<td><input type=password name=pass></td></tr>";
    echo 
"<tr><td colspan=2 align=center>";
    echo 
"<input type=submit value=\"Log in\"></td></tr>";
    echo 
"</table></form>";
  }
?>
<br>
<a href="members_only.php">Members section</a>
           
          
          </td>
    
        </tr>
      </table>
     <!-- End of  main content area  -->
      </td>
  </tr>
  <tr>
    <td height="30">
    <?php include("includes/footer.php"); ?>
    </td>
  </tr>
</table>
</body>
</html>
Can anyone help?.... please

Matt