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

Building a Mailing List Manager CHAPTER 28 675 LISTING Continued else { echo “Sorry, that email address is already registered here.”; echo “You will need to log in with that address to change “ .” Web settings.”; return false; } } else // new account { $query = “insert into subscribers values (‘$details[email]’, ‘$details[realname]’, ‘$details[mimetype]’, password(‘$details[new_password]’), 0)”; if(db_connect() && mysql_query($query)) { return true; } else { echo “Could not store new account.”; return false; } } } } 28 BUILDING A MAILING LIST MANAGER This function first checks that the user has filled in the required details. If this is okay, the function will then either. | Building a Mailing List Manager 675 Chapter 28 Listing Continued else echo p Sorry that email address is already registered here. echo p You will need to log in with that address to change . Web settings. return false else new account query insert into subscribers values details email details realname details mimetype password details new_password 0 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 exists. A user can only update the account details of the user he is logged in as. This is checked using the get_email function which retrieves the email address of the user who is currently logged in. We ll return to this later as it uses session variables that are set up when the user logs in. Logging In If a user fills in the login form we saw back in Figure and clicks on the Log In button she will enter the script with the email and password variables set. This will activate the login code which is in the pre-processing stage of the script as follows 28 Building a Mailing List Manager Building Practical PHP and MySQL Projects 676 Part V Listing Continued need to process log in or out requests before anything else if email password login login email password if login admin status . p b .get_real_name email . b logged in . successfully as b Administrator b br br br br br admin_user email session_register admin_user else if login normal status . p b .get_real_name email . b logged in . successfully. br br normal_user email session_register normal_user else status . p Sorry we could not log you in with that email address and password. br As you can see we first try to log them in using the login function from the library. This is slightly different from the login functions we .

TỪ KHÓA LIÊN QUAN
Đã 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.