3

So I have a 2 page registration page where on the first page the user inputs all his/her data and then clicks continue. On the 2nd page, they choose certain options and then click continue there, this will then take them somewhere else where their payments can be handled (not related to me at all).

I also have a Insert.php file that simply inserts all the user's data into the database. When clicking submit on page2, it actually redirects them to Insert.php, which inserts and then redirects them to the external payment page. I had to do this because for some reason the ajax call just wouldn't work.

My question is, what if right after they click submit on the 2nd page, their computer crashes or they close the browser? Will mysql understand that the connection has been terminated and not save anything or will it save partial data (as much as it could before the user crashed), and if so how do I delete the partial data?

At this point I'm just trying to do as much error handling as I can to prevent any serious problems down the road.

John Bernal
  • 230
  • 5
  • 21
  • You'll need to show us some code and maybe a screenshot of your DB structure (if possible). If the user's browser crashes before they get to save any info on the 2nd page, mySQL won't know about it. – Wayne Whitty Sep 21 '12 at 09:21

1 Answers1

0

When they click submit, if the browser sends all the post fields, the code you have will happily carry on executing. As far as the server is concerned, nothing of any importance happened.

I would suggest having some post/get checking in the code (as always) which will make sure that all the data has been passed. If it has, it will save properly for the user.

Edit: If you are worried about only some elements of the form being sent before a crash, you can do something like this:

if(!empty($_POST['someElement']) && !empty($_POST['someElement2']) && !empty($_POST['someElement2']))
{
    //All your elements are fully submitted, you can save the data safely
}
Fluffeh
  • 33,228
  • 16
  • 67
  • 80