PHP/MySQL/Flash login system problem

I have a working login system in Flash. Here’s the code in login.php:
**
<?php

if (isset($_POST[‘username’]) && isset($_POST[‘pwd’])) {

require_once('database.php');

if (!get_magic_quotes_gpc()) {
foreach($_POST as $key=&gt;$value) {
$temp = addslashes($value);
$_POST[$key] = $temp;
}

}

include(’…/connect.inc’);

$sql = ‘SELECT * FROM users WHERE username = "’.$_POST[‘username’].’" AND password = “’.$_POST[‘pwd’].’”’;
$result = $db->query($sql);

if ($result->num_rows > 0) {
echo ‘authenticated=ok’;
}
else {
echo ‘authenticated=getLost’;
}

$db-&gt;close();

}
?>**

This works fine but what would I need to add to be able to greet the user by their first name once they’re logged in? In the database I have several rows like username, password, email, firstname, lastname…

Any help would be appreciated!