btw, paypal has apis for this
they have an instant notification system that will send a request via post to the url you specify and give you the transaction details. you just have them send the data to your script and then you add the data to your db
sandbox.paypal.com