Specifications
We identify the administration user after login by means of the $admin_user session variable
and the check_admin_user() function. This function and the others used by the administrative
scripts can be found in the function library admin_fns.php.
If the administrator chooses to add a new category or book, she will go to either
insert_category_form.php or insert_book_form.php, as appropriate. Each of these scripts
presents the administrator with a form to fill in. Each is processed by a corresponding script
(insert_category.php and insert_book.php), which verifies that the form is filled out and
inserts the new data into the database. We will look at the book versions of the scripts only, as
they are very similar to one another.
The output of insert_book_form.php is shown in Figure 25.13.
Building Practical PHP and MySQL Projects
P
ART V
578
FIGURE 25.13
This form allows the administrator to enter new books into the online catalog.
You will notice that the Category field for books is an HTML SELECT element. The options for
this SELECT come from a call to the get_categories() function we have looked at previously.
When the Add Book button is clicked, the insert_book.php script will be activated. The code
for this script is shown in Listing 25.18.
31 7842 CH25 3/6/01 3:39 PM Page 578










