Once the log in credentials have been verified, you should set a session for the user using the username they used to log in with. For example:
$_SESSION['username'] = $_POST['username'];
That code basically sets a session, and places the username into that session.
On the next page (where you want the greeting message), you would have to grab the username from that session and display it. For example:
$username = $_SESSION['username'];
echo "Welcome back, $username!";