13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

722 Chapter 30 Building a Mailing List Manager<br />

Figure 30.10<br />

The administrator menu allows for mailing list creation <strong>and</strong><br />

maintenance.<br />

Creating a New List<br />

If the administrator chooses to set up a new list by clicking on the Create List button,<br />

she will activate the create-list action, which is associated with the following code:<br />

case 'create-list':<br />

display_list_form(get_email());<br />

break;<br />

The display_list_form() function, found in the output_fns.php library, displays a<br />

form that enables the administrator to enter the details of a new list. It just outputs HTML,<br />

so we did not include it here.The output of this function is shown in Figure 30.11.<br />

When the administrator clicks on the Save List button, this activates the store-list<br />

action, which triggers the following code in index.php:<br />

case 'store-list':<br />

if(store_list($_SESSION['admin_user'], $_POST)) {<br />

echo "New list added.";<br />

display_items('All Lists', get_all_lists(), 'information',<br />

'show-archive','');<br />

} else {

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!