Specifications

case ‘store-list’ :
{
if(store_list($admin_user, $HTTP_POST_VARS))
{
echo “<p>New list added<br>”;
display_items(“All Lists”, get_all_lists(), ‘information’,
‘show-archive’,’’);
}
else
echo “<p>List could not be stored, please try “
.”again.<br><br><br><br><br>”;
break;
}
As you can see, the code tries to store the new list details and then displays the new list of lists.
The list details are stored with the
store_list() function. The code for this function is shown
in Listing 28.13.
L
ISTING 28.13 store_list() Function from mlm_fns.phpThis Function Inserts a New
Mailing List into the Database
function store_list($admin_user, $details)
{
if(!filled_out($details))
{
echo “All fields must be filled in. Try again.<br><br>”;
return false;
}
else
{
if(!check_admin_user($admin_user))
return false;
// how did this function get called by somebody not logged in as admin?
if(!db_connect())
{
return false;
}
$query = “select count(*) from lists where listname = ‘$details[name]’”;
$result = mysql_query($query);
if(mysql_result($result, 0, 0) > 0)
{
echo “Sorry, there is already a list with this name.”;
return false;
}
Building Practical PHP and MySQL Projects
P
ART V
694
34 7842 CH28 3/6/01 3:46 PM Page 694