Specifications
LISTING 28.13 Continued
$query = “insert into lists values (NULL,
‘$details[name]’,
‘$details[blurb]’)”;
$result = mysql_query($query);
return $result;
}
}
This function performs a few validation checks before writing to the database: It checks that all
the details were supplied, that the current user is an administrator, and that the list name is
unique. If all goes well the list is added to the lists table in the database.
Uploading a New Newsletter
Finally we come to the main thrust of this application: uploading and sending newsletters to
mailing lists.
When an administrator clicks on the Create Mail button, it activates the create-mail action,
as follows:
case ‘create-mail’ :
{
display_mail_form(get_email());
break;
}
The administrator will see the form shown in Figure 28.12.
Remember that for this application we are assuming that the administrator has created a
newsletter offline in both HTML and text formats and will upload both versions before send-
ing. We chose to implement it this way so that administrators can use their favorite software to
create the newsletters. This makes the application more accessible.
You can see that this form has a number of fields for an administrator to fill out. At the top is a
drop-down box of mailing lists to choose from. The administrator must also fill in a subject for
the newsletter—this is the Subject line for the eventual email.
All the other form fields are file upload fields, which you can see from the Browse buttons
next to them. In order to send a newsletter, an administrator must list both the text and HTML
versions of this newsletter (although obviously you could change this to suit your needs).
There are also a number of optional image fields where an administrator can upload any
images that she has embedded in her HTML. Each of these files must be specified and
uploaded separately.
Building a Mailing List Manager
C
HAPTER 28
28
BUILDING A
MAILING LIST
MANAGER
695
34 7842 CH28 3/6/01 3:46 PM Page 695