tailieunhanh - PHP and MySQL Web Development - P107

PHP and MySQL Web Development - P107: 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. | 502 Chapter 24 Building User Authentication and Personalization Note that fopen will only be able to open files if your server has direct access to the Internet. If it needs to access other HTTP servers via a proxy server fopen will not work. This function and the others relating to bookmarks are all in the function library can see the code for the add_bm function in Listing . Listing The add_bm function from This Function Adds New Bookmarks to the Database function add_bm new_url Add new bookmark to the database echo Attempting to add .htmlspecialchars new_url . br global HTTP_SESSION_VARS valid_user HTTP_SESSION_VARS valid_user if conn db_connect return false check not a repeat bookmark result mysql_query select from bookmark where username valid_user and bm_URL new_url if result mysql_num_rows result 0 return false insert the new bookmark if mysql_query insert into bookmark values valid_user new_url return false return true This function is fairly simple. It checks that a user does not already have this bookmark listed in the database. Although it is unlikely that users would enter a bookmark twice it is possible and even likely that they might refresh the page. If the bookmark is new then it is entered into the database. Looking back at you can see that the last thing it does is call get_user_urls and display_user_urls the same as ll move on and look at these functions next. Displaying Bookmarks In the script and the add_bm function we used the functions get_user_urls and display_user_urls .These functions get the user s bookmarks Implementing Bookmark Storage and Retrieval 503 from the database and display them get_user_urls function is in the library and the display_user_urls function is in the library. The get_user_urls function is shown in Listing . Listing The get_user_urls Function from This Function Retrieves a .

TỪ KHÓA LIÊN QUAN