this is an inherent problem with the way that paypal payments standard works.
with paypal standard, you need to store the order before the transaction is precessed, set the status of the porder to pending, then use an IPN page to update the order.
the workflow of PayPal standard is this:
user fills in the checkout form and goes to the confirm page, on loading the confirm page, the order is stored in the database.
the confirm page posts the information to the paypal servers.
On the paypal server the costumer enters their information for how the transaction should be processed.
The paypal server excepts or denies this information and directs the user to the success or failure page.
At this point the transaction is line to be processed. it can take 30 seconds or 5 days for the transaction to got through. Once the transaction is processed the IPN post is made by paypal servers to the page you specify.
The drawback of paypal payments standard is that it is not processed real time the IPN page is never seen by the customer.
Instead of using payPal Payments standard, i would recommend using Paypal Express checkout, this is a free paypal option that is processed real time and does not require using an IPN post.