Script 12.12
Your Website
catchy slogan...
Login
<?php # Script 12.12 - login.php #4 // This page processes the login form submission. // The script now stores the HTTP_USER_AGENT value for added security. // Check if the form has been submitted: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // For processing the login: require (CHAPTER_PATH.'/'.$chapter.'/includes/12.2.php'); // Need the database connection: require (CONNECT); // Check the login: list ($check, $data) = check_login($link, $_POST['email'], $_POST['pass']); require(DISCONNECT); // Close the database connection. if ($check) { // OK! // Set the session data: $_SESSION['user_id'] = $data['user_id']; $_SESSION['first_name'] = $data['first_name']; $_SESSION['last_name'] = $data['last_name']; // Store the HTTP_USER_AGENT: $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']); if(isset($_SESSION['errors'])) { unset($_SESSION['errors']); unset($_SESSION['email']); } // Redirect: redirect_user('index.php?chapter=12&path=using+sessions&script=12.13'); } else { // Unsuccessful! $errors = $data; $_SESSION['errors'] = $data; $_SESSION['email'] = $_POST['email']; redirect_user('index.php?chapter=12&path=using+sessions&script=12.12'); } } // End of the main submit conditional. // Create the page: include (CHAPTER_PATH.'/'.$chapter.'/includes/12.1.php'); ?>