1. <?php // Script 8.8 - login.php
2. /* This page lets people log into the site (in theory). */
3.
4. // Set the page title and include the header file:
5. define('TITLE', 'Login');
6. require('templates/header.html');
7.
8. // Print some introductory text:
9. print '<h1>Login Form</h1>
10. <p>Users who are logged in can take advantage of certain features like this, that, and the other thing.</p>';
11.
12. // Check if the form has been submitted:
13. if ( isset($_POST['submitted']) ) {
14.
15. // Handle the form:
16. if ( (!empty($_POST['email'])) && (!empty($_POST['password'])) ) {
17.
18. if ( (strtolower($_POST['email']) == 'me@example.com') && ($_POST['password'] == 'testpass') ) { // Correct!
19.
20. print '<p>You are logged in!<br />Now you can blah, blah, blah...</p>';
21.
22. } else { // Incorrect!
23.
24. print '<p>The submitted email address and password do not match those on file!<br />Go back and try again.</p>';
25.
26. }
27.
28. } else { // Forgot a field.
29.
30. print '<p>Please make sure you enter both an email address and a password!<br />Go back and try again.</p>';
31.
32. }
33.
34. } else { // Display the form.
35.
36. print '<form action="login.php" method="post">
37. <p>Email Address: <input type="text" name="email" size="20" /></p>
38. <p>Password: <input type="password" name="password" size="20" /></p>
39. <p><input type="submit" name="submit" value="Log In!" /></p>
40. <input type="hidden" name="submitted" value="true" />
41. </form>';
42.
43. }
44.
45. require('templates/footer.html'); // Need the footer.
46. ?>