Hello, I have started writing an installer for my script. The installer consists of these steps:

step0:
- Check if already installed (install lock file), if not start installation

step1:
- Display welcome page

step2:
- Collect site name, site slogan, site url and site path
- Check for errors, if no errors write variables to session variables and goto step3

step3:
- Check directories requirements (if they exist and are writable)
- Check until all directories are created and writable. If yes goto step4

step4:
- Collect database info (dbhost, dbname, dbuser, dbpass)
- Check for errors, if no errors try to connect and select the db.
- If no connection, repeat step4
- If there is connection and db is selected, write values to session variables and goto step5.

step5:
- Summarize and review all variables
- Display option of installing the sample data as well.
- goto step6

step6:
- Insert MySQL dump into DB using the session variables.
- Insert sample data if requested.
- Insert additional info (Site name, site slogan etc.). from session variables.
- Create install lock file.
- Display "Installation Complete" page and "Take me to the site" button.
- Display option of attempting to delete this installer file before going to the actual site.
- If checked, delete this installer file. If not successful, prompt the admin to delete the file by hand on the actual site.


This is my first attempt to write an installer, so I may have complicated things or not foresee some errors. I still have difficulties at step6 at inserting the MySQL dump into DB. Any advices?