|
|
|
|||||||
|
||||||||
|
|
|
|||||||
Handout #3 - CSCI 244201 - Inside the htdocs directory, create a new directory called handout3. This directory will contain three files, index.htm, page2.php and image1.jpg. Find a interesting photo to display when the user successfully logs in and place it in this directory, renaming the photo image1.jpg. 02 - The file index.htm will contain a table with five rows and two columns. The first row should contain a prompt for the user name, followed by a text input called username. The second row should contain a prompt for password, followed by a password input called password1. The third row should contain a prompt to confirm the pasword, followed by a password input called password2. The fourth row should ask if the person is a new user, followed by two radio buttons with values of yes and no. The no radio button should be checked by default. The sixth row will only contain a submit button with the value of "Sign On". The entire form should use the post method and have an action directing the results to page2.php. In addition, please use CSS statements in the body tag to customize background color, text color and font family for this document. Please apply the same values in the body tags used inside page2.php. 03 - The file page2.php should be entirely php and start off defining four variables called $username, $password1, $password2 and $newuser. Set these variables equal to the values passed in from index.htm. In addition, define two indexed arrays called $userlist1 and $passlist1, populated with the following values: For $userlist1: For $passlist1: 1 => 'jsmith', 1 => 'mg128ggg', 2 => 'djohnson', 2 => 'jj987aaa', 3 => 'mhanson', 3 => 'qw549klm', 4 => 'lgray', 4 => 'yt612nbv', 5 => 'bpeterson' 5 => 'lk812gfr' 04 - The remainder of page2.php will be divided into five sections called Section A through E, printing our the various messages described in the flowchart presented in class. After the various control structures for each section, the first line of each section will contain a comment stating the Section name, followed by a description of what conditions have been met to displat the code in this section. This will be followed by a print statement containing <html> and <head> tags. The last two lines of each section will contain a print statement with </body> and </html> tags, followed by the exit command as discussed in class. Please apply the CSS styles mentioned in Step 2 to the <body> tag in each of these sections. 05 - The control structure for Section A should first check if the value of $newuser equals yes. If so, use a foreach loop to move through the $userlist array. Check if the variable $username matches any of the entries in the array $userlist. If they do, print a title statement containing the message "Sorry - $username is already in use." This should be followed by a meta refresh tag, redirecting the user back to index.htm in 10 seconds. In the body section, display the message "Sorry, the username $username is already taken. Please login again and select a different username. If you are not redirected to the login page after ten seconds, please click here." Insert the appropriate links, close the body and html tags and end the section with an exit statement. 06 - The control structure for Section B will be inside the test for $newuser equals yes and will be activated if there was not a match inside the foreach statement in Step 5. It should begin with a title statement saying $username is available. There should NOT be a refresh meta tag inside this section. The body should contain the message "The username $username is currently available. However the new user account creation page is currently under construction. Please return back here soon for updates." Close the body and html tags and end the section with an exit statement. 07 - The control structures for Sections C, D and E is outside of the test for $newuser equals yes. Since $newuser can only have one of two possible values, it is assummed that $newuser is equal to no for these three sections. For Section C, test if password1 is NOT equal to password2. If the passwords do not match, print out a title with the phrase "Sorry - Password Mismatch", followed by a meta tag similar to the one in Step 5. The body section should display the message "Sorry. Two different values were entered for the password fields. Please login again and use the same password for both entries. If you are not redirected to the login page after ten seconds, please click here." Insert the appropriate links, close the body and html tags and end the section with an exit statement. 08 - The control structures for Sections D and E will be inside the section where password1 is equal
to password2. For section D, use a foreach structure with the following syntax:
09 - Section E will be displayed only if none of the username/password input variables did not match any of the values in the array. Display a title with the message "Sorry - Username/Password Incorrent" followed by a meta refresh tag like the one from Step 5. In the body, display the message "Sorry. The username and/or password you entered are not valid. Please login again and double check that CAPS LOCK is not on. If you are not redirected to the login page after ten seconds, please click here." Insert the appropriate links, close the body and html tags and end the section with an exit statement. Insert the closing php tags after this section. 10 - Test out the these two pages under the following conditions:
TEST 1 TEST 2 TEST 3 TEST4 TEST5
----------------------------------------------------------
username jsmith fcrawford djohnson mhanson lgray
password1 a a a qw549klm lk812gfr
password2 a a b qw549klm lk812gfr
newuser yes yes no no no
----------------------------------------------------------
Turn in printouts of the local source code for index.htm and page2.php, along with screenshots for test case 2 and 4. Be ready to demonstrate all five cases in class the day the assignment is due. A working example of this code can be found HERE BACK |
||||||||