Đang chuẩn bị liên kết để tải về tài liệu:
PHP and MySQL Web Development - P134

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

PHP and MySQL Web Development - P134: 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. | Implementing Login 637 Here the form is blank ready for new account details. Because this function only outputs HTML we will not go through it here. Figure 28.5 The new account creation form enables users to enter their details. The submit button on this form invokes the store-account action.The code for this action is as follows case store-account if store_account HTTP_SESSION_VARS normal_user HTTP_SESSION_VARS admin_user HTTP_POST_VARS action if check_logged_in display_login_form action break The store_account function writes the account details to the database. The code for this function is shown in Listing 28.4. 638 Chapter 28 Building a Mailing List Manager Listing 28.4 store_account Function from mlm_fns.php These Functions Add a New User or Modify an Existing User in the Database. add a new subscriber to the database or let a user modify their data function store_account normal_user admin_user details if filled_out details echo All fields must be filled in. Try again. br br return false else if subscriber_exists details email check logged in as the user they are trying to change if get_email details email query update subscribers set realname details realname mimetype details mimetype where email . details email . if db_connect mysql_query query return true else echo could not store changes. br br br br br br return false else echo p Sorry that email address is already registered here. p echo p You will need to log in with that address to change . its settings. p return false else new account query insert into subscribers values details email details realname details mimetype password details new_password 0 Implementing Login 639 Listing 28.4 Continued if db_connect mysql_query query return true else echo Could not store new account. br br br br br br return false This function first checks that the user has filled in the required details. If this is okay the function will then either create a new user or update the account details if the user already .