Specifications

As you can see, we then execute the display_account_setup() function as before to list the
users account details. The newly added account will now be included.
Modifying an Existing Account
The process for modifying an existing account is very similar. The user can change the account
details and click the Save Changes button. Again this will trigger the store-settings action,
but this time it will update the account details instead of inserting them.
Deleting an Account
To delete an account, the user can click the Delete Account button that is shown under each
account listing. This activates the
delete-account action.
In the preprocessing section of the index.php script, we will execute the following code:
case ‘delete-account’ :
{
delete_account($auth_user, $account);
break;
}
This code calls the delete_account() function. The code for this function is shown in Listing
27.6. Deleting accounts needs to be handled before the header because a choice of which
account to use is inside the header. The account list needs to be updated before this can be cor-
rectly drawn.
LISTING 27.6 delete_account() Function from mail_fns.phpFunction to Delete a Single
Accounts Details
function delete_account($auth_user, $accountid)
{
//delete one of this user’s accounts from the DB
$query = “delete from accounts where
accountid=’$accountid’ and
username = ‘$auth_user’”;
if(db_connect())
{
$result = mysql_query($query);
}
return $result;
}
Building Practical PHP and MySQL Projects
P
ART V
636
33 7842 CH27 3/6/01 3:41 PM Page 636