This creates a script that shows the form when there is no input or otherwise enters the information into the database. How does the script understand when to do what? We have already learned that PHP automatically creates variable with information posted to it. So it will create the variable $submit if the form is posted. The script determines whether there exists the variable $submit. If it exists and contains a value then we have to enter the posted values into the database; otherwise, we have to show the form.
So now we can enter information to our database and view it. Try inserting some new data into the database and check to see if it really works by viewing them with viewdb.php.