I need an example of how to use php and ajax to insert data into the database

The script is the same as your previous topic where it was suggested to use error reporting. Apparently you managed to solve the problem and declined to enlighten other users with the solved solution.

Why do you think it is not necessary to use error reporting on this new problem?

Also as mentioned before the script is confusing, one particular aspect is the unnecessary toggling of the $good variable. A simplified version was given which is not implemented. Why insist on using the original script?