For this project, you will be building upon the HTML/CSS website you made for project 1. You will be adding basic login functionality, cookies, and form validation.
Your site should:
1. Include a login form
- Your form should have a textbox for the username, a password textbox for the password, and a submit button.
- Your form should use a separate PHP file for its action that checks to see if the user input matches the following – username: dig3134user password: dig3134pass
- If the user enters the correct credentials, the user should be given a success message and then redirected to an appropriate page of your choosing. It should be clear to the user that they have successfully logged in.
- If the user enters incorrect credentials, they should be sent back to the login form, and be presented with an appropriate error message.
- If the user’s input matches the login information I presented above, you should store/modify a cookie to save the user’s login state. If the cookie states the user is logged in, the login form should not display. If the cookie does not state the user is logged in, the login form should display (allowing the user to log in).
- Your site should differ in some meaningful way for logged in vs logged out users. What should a logged in user be able to see/do that a logged out user cannot see/do? You must tell me how your site differs in the submission comments.
- You should include a logout button / link on your page that will modify the cookie so that the user is no longer logged in.
3. Include an account creation form
- Your form should include the following fields, at a minimum: Username, Password, Phone Number, E-mail Address, Street, City, Zip Code State
- Implement validation on your site’s account creation page. Output specific error messages (“State must be two capital letters”) when validation fails.
- Zip code should be exactly 5 numbers.
- State should be exactly 2 letters.
- Street should begin with a number and end with a letter.
- Phone number should first be stripped of its parentheses, dashes (-), and spaces using preg_replace
- Phone number should be exactly 10 characters long and only contain numbers (US number with no country code)
4. After validation succeeds:
- The user input on the HTML form should be processed on the same PHP webpage (i.e., the action should be blank. Do not refer to an external PHP page).
- Make sure you use the POST method.
- Output “You have successfully created an account, [username]. You will be redirected to the homepage in 5 seconds.” Use the correct index in the array to output the username.
- The user should then be redirected to the homepage after 5 seconds.
5. Include an original PHP element of your choosing. This original element is something that was not taught in class or my supplemental videos, but that you learned on your own by doing research.