tailieunhanh - PHP and MySQL Web Development - P92

PHP and MySQL Web Development - P92: 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. | Further Reading 427 valid_user is set. If the user is logged in we show her the members content otherwise we tell her that she is not authorized. Finally we have the script that signs a user out of the code for this script is shown in Listing . Listing This Script Deregisters the Session Variable and Destroys the Session php session_start old_user HTTP_SESSION_VARS valid_user store to test if they were logged in unset HTTP_SESSION_VARS valid_user session_destroy html body h1 Log out h1 php if empty old_user echo Logged out. br else if they weren t logged in but came to this page somehow echo You were not logged in and so have not been logged out. br a href Back to main page a body html The code s very simple but we do a little fancy footwork. We start a session store the user s old username unset the valid_user variable and destroy the session. We then give the user a message that will be different if she was logged out or was not logged in to begin with. This simple set of scripts will form the basis for a lot of the work we ll do in later chapters. Further Reading Native sessions are new to PHP 4 but sessions have been provided by PHPLib for a best things to read for more information are the PHPLib homepage and the 428 Chapter 20 Using Session Control in PHP cookies ve listed both these URLs earlier in the chapter but we ll reprint them here for reference http http newsref std Next We re almost finished with this section of the book. Before we move on to the projects we ll briefly discuss some of the useful odds and ends of PHP that we haven t covered elsewhere. 21 Other Useful Features S OME USEFUL PHP FUNCTIONS AND FEATURES do not fit into any particular category. This chapter will explain these features. We ll look at Using magic quotes Evaluating strings with eval Terminating execution die and exit Serialization Getting .

TỪ KHÓA LIÊN QUAN