Page 332 - Beginning PHP 5.3
P. 332
Part III: Using PHP in Practice
Figure 10-4
Figure 10-5
H ow I t W orks
The script starts by creating a new session (or picking up an existing one) with session_start() .
Then it defines a couple of constants, USERNAME and PASSWORD , to store the predefined login details.
(In a real Web site you would probably store a separate username and password for each user in a
database table or text file.)
session_start();
define( “USERNAME”, “john” );
define( “PASSWORD”, “secret” );
Next the script calls various functions depending on user input. If the Login button in the login form
was clicked, the script attempts to log the user in. Similarly, if the Logout link was clicked, the user is
294
9/21/09 9:05:17 AM
c10.indd 294 9/21/09 9:05:17 AM
c10.indd 294