TAILIEUCHUNG - Phát triển web với PHP và MySQL - p 67

Building a Web-Based Email Service CHAPTER 27 635 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)) { echo “All fields must be filled in. Try again.”; 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.”; return false; } }. | Building a Web-Based Email Service 635 Chapter 27 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 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 to the main body stage case store-settings case account-setup case delete-account display_account_setup auth_user break 27 Building a Web-Based Email Service Building Practical PHP and MySQL Projects 636 Part V As you can see we then execute the display_account_setup function as before to list the user s 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 script we will execute the following code case delete-account delete_account .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.