结构数据库插入和逻辑

I am just wanting to find out really how everyone else does things, as I think my ways are a bit flawed.

I have written a few pages of code that will take a person's details, send the person to a payment page, and then return them to the clients website to a thank you page (or transaction failed if that is the case).

However, let us assume that there are three stages:

  1. Get details.
  2. Get further details if neccessary.
  3. Confirm details and click button to be taken to card processor.

Now, I have always been inserting my data at point 3, as I dont want to lose the information stored in sessions. Then when the user comes to a thank you page, the table is updated and marked as transaction confirmed. This works, but it seems messy.

The problem is I end up with many useless database entries, it would seem alot of people get to stage three and dont go any further. What I want is a table full of people that have paid and are verified. So to counter this, I have created tmp_ tables, where the data is stored, and then when the verification comes through, I move all the data over into real tables.

This still seems highly convoluted to me and there must be a better solution. One of the biggest pains is that final 'Pay By Card' button in stage three, If it could do two things at once ($_POST to my website and redirect the user to the card processing page) - And I understand that this could be achieved with javascript but I still think that's a messy way to go about things, and a bit untrustworthy too.

Solutions/Suggestions please? I am here to learn.