I spent a long time figuring this out on the internet so I will post this now to hopefully help others with the same problem.
this is to display the currently logged in user using mysql.
this is so they log in with a username, and it displays actual name.
//connect to your database
<?php require_once(mysqlconn.php');
//initialize the session
if (!isset($_SESSION)) {
session_start();
}
//rest of your php scripts can go here
$user = $_SESSION['MM_Username'];
mysql_select_db($database_table, $table);
$query_Recordset1 = "SELECT * FROM table WHERE username='$user'";
$Recordset1 = mysql_query($query_Recordset1, $table) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
//echo the name
echo $row_Recordset1['name']; ?>
you need a login page which sets the login username to MM_Username
and a restrict access server behaviour otherwise it just wont work.
hope this is helpful to people.