|
Exercise #20 (Due Friday)
|
Turn in:
- A zip file named your "Lastname, Firstname" containing:
- index.php
- login.php
- page1.php
- page2.php
- page3.php
- error.php
This exercise will focus on a login screen with 3 different users. All of the information
will be hardcoded (not database-driven). Use
Dreamweaver to complete this assignment. It is suggested that you use Dreamweaver for all parts of this assignment..
The purpose of this exercise is to (a) get you familiar with $_POST, (b) require you to implement an if-else if-else control structure, and (c) teach you how to redirect to a new page using header().
- You CANNOT run these pages from anywhere other than a web server. You MUST save them to your www folder, then navigate to them in the browser similar to this: http://web.ics.purdue.edu/~yourCareerAcct/cgt141/ec20/index.php
- You CANNOT have any spaces in your file names or folder names.
- You CANNOT have any special characters in your file names or folder names.
- Create 4 "skeleton" XHTML pages (with .php extensions) that will be the pages that each user sees after they login. Name each of these documents "page1.php", "page2.php", "page3.php", and "error.php".
- The first line of each of these documents should use the XHTML strict
DTD for the <!doctype> tag.
- Inside the <body> of each of the skeleton XHTML pages, add a single <h2>...</h2>
element and place the name of the file in between the opening and closing
tags. This is all of the content you will have in these documents.
- Set the <title> of each page to the name of the file.
- Additionally, on error.php, add the statement "click here to return to the login screen" with the word "here" being hyperlinked back to "index.php"
- There will not actually be any PHP in these 4 pages. It will only be XHTML. The files will have the .php file extension though.
- index.php (page containing login and password boxes)
- Create a form with a "login" and "password" textbox and a "submit" button.
- Set the method to "post" and the action to "login.php"
- Be sure to name all of your form elements.
- Provide a label for each text box so that the user knows what they are typing.
- login.php (verification & redirection) (this is called a "Pass-Through" page or "Processing" page)
- This page has NO XHTML whatsoever. It is only PHP.
- Use $_POST to get the value that was typed into the textboxes.
- Store the values from $_POST into variables. Then use the variables in your if statements. Remember that variables in PHP start with: $
- The comparison operator in PHP is: ==
- The logical and operator in PHP is: &&
- Use the header() method to redirect to the appropriate location.
- If login = page1 and password = alpha
- If login = page2 and password = beta
- If login = page3 and password = gamma
- The login and password must both match exactly,
- Else Redirect to error.php
- Make sure it works on the server!!!
Image of the login screen in the solved exercise: Exercise 20
|
|
| |