Eric,
If you have auto return enabled on paypal, you will automatically be sent back to the page you specify, and paypal attaches a auth token to the querystring.
If you post this token back to paypal, and it matches, paypal will respond with an array of values containing all of the info about the transaction, including the transaction ID, payment type etc.
You can then match this data with your order id, double check that the amounts match, and that the status is SUCCESS, and then, based on that update your orders table, and send out the emails.
Tom