Change this to
if ($a[admin] == Y)
{
$_SESSION['admin'] = 1;
$_SESSION['username'] = $a['username'];
header('location: admin.php');
}
else
{
$_SESSION['user'] = 1;
$_SESSION['username'] = $a['username'];
header('location: index2.php');
}
Now use this $_SESSION['username'] to show user name on your web page.