May 2003
Intermediate to advanced
592 pages
14h 28m
English
In Chapter 7, “Cookies and Sessions,” I wrote many versions of the login.php and logout.php scripts, using variations on cookies and sessions. Here I’ll develop standardized versions of both that stick to the practices of the whole application.
1. | Create a new document in your text editor (Script 12.7).
<?php # Script 12.7 - login.php |
2. | Require the configuration file and the HTML header.
require_once ('includes/config.inc');
$page_title = 'Login';
include ('includes/header.html');
|
3. | Check if the form has been submitted, require the database connection, and validate the submitted data.
if (isset($_POST['submit'])) { require_once ('../mysql_connect.php'); if (empty($_POST['username'])) { ... |