What to do when this happens?

-1

I'm working on a system in which I must register various data from a form in different tables using mysql. It works like this: The person does a registration and in the same form requests a special attention, I save his data normally and with his ID, which is generated by self-increment, I save the data of the request [id, ...]. If all goes right, beauty. But the question is, what if the application file goes wrong? Should I delete the user, give the error message and return to the register for it to register again? What's the best way out?

    
asked by anonymous 24.05.2017 / 21:06

1 answer

2

Well, let's see if I understand ... you get data from an example form: name, cpf, request, category in case you want to save name and cpf in one table and request and category in another correct? >

then:

save name, cpf in table1

verify if id was generated from table1 if it has been generated, get this id

and uses to save the request, category in table2

If you give an error when saving to table2, the correct one would be to delete the row from table1 where id is what you got and then show a message to the customer saying that there was a problem with the registration and that he should try again.

I hope to have helped !!!

    
25.05.2017 / 05:03