Specifications
LISTING 27.5 store_account_settings() Function from mail_fns.php—Function to Save
New Account Details for a User
function store_account_settings($auth_user, $settings)
{
if(!filled_out($settings))
{
echo “All fields must be filled in. Try again.<br><br>”;
return false;
}
else
{
if($settings[‘account’]>0)
$query = “update accounts set server = ‘$settings[server]’,
port = $settings[port], type = ‘$settings[type]’,
remoteuser = ‘$settings[remoteuser]’,
remotepassword = ‘$settings[remotepassword]’
where accountid = $settings[account]
and username = ‘$auth_user’”;
else
$query = “insert into accounts values (‘$auth_user’,
‘$settings[server]’, $settings[port],
‘$settings[type]’, ‘$settings[remoteuser]’,
‘$settings[remotepassword]’, NULL)”;
if(db_connect() && mysql_query($query))
{
return true;
}
else
{
echo “could not store changes.<br><br><br><br><br><br>”;
return false;
}
}
}
As you can see, two choices within this function correspond to inserting a new account or
updating an existing account. The function executes the appropriate query to save the account
details.
After storing the account details, we go back to index.php, to the main body stage:
case ‘store-settings’ :
case ‘account-setup’ :
case ‘delete-account’ :
{
display_account_setup($auth_user);
break;
}
Building a Web-Based Email Service
C
HAPTER 27
27
BUILDING A
WEB-BASED
EMAIL
SERVICE
635
33 7842 CH27 3/6/01 3:41 PM Page 635










