doing this with paypall standard is problematic and not very easy.
when the checkout page posts to the confirm page, the order summary and details are stored in the database, you could update the product table at this time also, then the user goes to paypal for payment and is returned to your site after completing payment.
the problem with standard, is that it is not a real time gateway. you need to configure an IP page that will accept the IPN post from paypal once the transaction goes through and update the product to sold at that time.
with payments pro, it's much easier, because it is a real time system, when the confirm page posts the details to the paypal gateway, the transaction is processed, if the funds are successfully sent to your account from the merchant bank, the order summary and details are stored, you could update the product status to sold at this time.