Workshop
Quiz
What function would you use to open a database using the DBA functions?
What function would you use to insert a record into a database?
What function would you use to replace a record in a database?
How would you access a record from a database by name?
How would you get the name (as opposed to the value) of the first element in a database?
How would you get subsequent element names?
How would you delete a named element from a database?
Quiz Answers
You can open a database with the dba_open() function.
The dba_insert() function adds a record to a database.
The dba_replace() function replaces a record in a database.
The dba_fetch() function returns an element given a DBA resource and the element's name.
dba_firstkey() returns the name of the first element in a DBM-like database.
After calling dba_firstkey(), you can get subsequent element names by calling dba_nextkey().
You can delete an element with dba_delete().
Activities
Create a database to keep track of user names and passwords. Create a script that allows users to register their combinations. Don't forget to check for duplications.
Create an authentication script that checks a user name and password. If the user input matches an entry in the database, present the user with a special message. Otherwise, re-present the login form to the user.