The login page will show a form where the user can type in the username and password. If he/she is authenticated, he/she will be redirected to his/her profile page. The profile page will show his/her basic information and can only be accessed when he/she is logged in. The user can log out by clicking on the link on the profile page.
1. Create a new file named
login.php
with the following code:<?php $action = (!empty($_POST['login']) && ($_POST['login'] === 'Log in')) ? 'login' : 'show_form'; switch($action) { case 'login': require('session.php'); require('user.php'); $user = new User(); $username = $_POST['username']; $password = $_POST['password']; if ($user->authenticate($username, $password)) { header('location: profile.php'); exit; } else { $errorMessage = "Username/password did not match."; break; } case 'show_form': default: $errorMessage = NULL; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0...