Right, look at the hidden fields in your original form, I don't see anywhere you're passing a variable from which you can extract $username. You can set a session variable before going over to payPal, but there are two problems with this.
First is that sessions inherently are cookie based, that is, setting a session sets the PHPSESSID cookie in your browser. If cookies are disabled, it will fail.
That one is **fairly** trivial, but one that is not: never rely on user action to compete a task. If you do, there is a very high possibility it will fail. I'm referring to the return to merchant link as the trigger to update your database - if they don't do this, it won't work. People don't like to read. :-)
What you want - nay, need - here is IPN, Instant Payment Notification - and it's not that hard to set up. You have most of the groundwork already. Here's how it works.
You go into PP and activate IPN, specify the IPN return URL. (Actually, you can specify return URL's just like above, but this is your starter script with IPN.) We'll call this a "listener script" which you haven't written yet.
On order, before sending them to payPal, you enter the data into your database and you have a field called something like "completed" which defaults to 0. Important in this is when you add the record, you obtain a unique id and pass it to payPal as trans_id.
They go to payPal, make the payment. And close the window, thinking they are done (which is what most users do.)
When paypal completes the transaction, it posts the trans_id of the completed transaction to your "listener script". You then look up the record, update the completed field to 1, send your emails, and whatever.
Though the biggest advantage is it no longer relies on sessions OR user action, it has another: you can now take eChecks. The IPN may not come for several days on an eCheck. No more zombie records, no more emails, then log in to PP and it's not complete . . . no more "Where's my stuff" emails.
These are just the cliff notes, look into IPN, there are samples on the payPal site for you to play with, it's very easy to set up.