PHP and MySQL Web Development - P103

PHP and MySQL Web Development - P103: 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. | 482 Chapter 24 Building User Authentication and Personalization Figure The registration form retrieves the details we need for the database. We get users to type their passwords twice in case they make a mistake. Listing This Script Validates the New User s Data and Puts It in the Database php include function files for this application require_once create short variable names email HTTP_POST_VARS email username HTTP_POST_VARS username passwd HTTP_POST_VARS passwd passwd2 HTTP_POST_VARS passwd2 start session which may be needed later start it now because it must go before headers session_start check forms filled in if filled_out HTTP_POST_VARS do_html_header Problem echo You have not filled the form out correctly - please go back . and try again. do_html_footer Implementing User Authentication 483 Listing Continued exit email address not valid if valid_email email do_html_header Problem echo That is not a valid email address. Please go back . and try again. do_html_footer exit passwords not the same if passwd passwd2 do_html_heading Problem echo The passwords you entered do not match - please go back . and try again. do_html_footer exit check password length is ok ok if username truncates but passwords will get munged if they are too long. if strlen passwd 6 strlen passwd 16 do_html_header Problem echo Your password must be between 6 and 16 characters. . Please go back and try again. do_html_footer exit attempt to register reg_result register username email passwd if reg_result true register session variable HTTP_SESSION_VARS valid_user username provide link to members page do_html_header Registration successful echo Your registration was successful. Go to the members page 484 Chapter 24 Building User Authentication and Personalization Listing Continued . to start setting up your bookmarks do_html_url Go to members page else otherwise provide link back tell them to try again do_html_header Problem .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
476    18    1    30-11-2024
Đã 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.