PHP and MySQL Web Development - P127: PHP and MySQL Web Development teaches the reader to develop dynamic, secure, commercial Web sites. Using the same accessible, popular teaching style of the first edition, this best-selling book has been updated to reflect the rapidly changing landscape of MySQL and PHP. | 602 Chapter 27 Building a Web-Based Email Service existing function is in the library it simply outputs HTML so we will not go through it here. The function that retrieves any existing accounts is get_accounts from the function is shown in Listing . Listing get_accounts Function from Function to Retrieve All the Account Details for a Particular User function get_accounts auth_user list array if db_connect query select from accounts where username auth_user result mysql_query query if result while settings mysql_fetch_array result array_push list settings else return false return list As you can see this function connects to the database retrieves all the accounts for a particular user and returns them as an array. Creating a New Account If a user fills out the account form and clicks the Save Changes button the store-settings action will be activated. Let s look at the event handling code for this from . In the preprocessing stage we execute the following code case store-settings store_account_settings HTTP_SESSION_VARS auth_user HTTP_POST_VARS break The store_account_settings function writes the new account details into the code for this function is shown in Listing . Listing store_account_settings Function from Function to Save New Account Details for a User function store_account_settings auth_user settings if filled_out settings Setting Up Accounts 603 Listing Continued 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 .