download the sample ipn php script, and just add some code where it tells you to. such as, db connection, then add a record into your database with a random username and password, then send them an email with this data. should be simple enough.
Oh and make sure you enable ipn on paypal's side, and direct it to the url of this script