Objectives:

Get exposure to PHP and GET and POST verbs and Session in PHP.

Description:

In this assignment, you will create a web application using PHP to do two things:

1. Handle GET and POST requests

2. Create a Login Page using Sessions.

You must style and theme your assignments.

You will lose points if your pages look bad/ugly.

Remember: Always put your name and a description in a block comment at the top of your code pages.

Part I: POST vs. GET

Create a web application that starts in a folder or subdomain on your domain that is similar to what I have done at the following website: http://teaching.jdholmes.net/postvget/ Though it will be similar, there will be a few exceptions.

Your code will do the following:

1. Have a form that accepts at least three visible fields and one hidden field.

a. Visible fields: i. First Name ii. Middle Name iii. Last Name

b. The hidden field’s value will be your name.

2. Provide data back to the server as either a POST or GET request.

a. You must provide both a POST and GET option.

b. This must be done using the same form.

i. Hint: use JavaScript to change between POST and GET.

3. On a separate page or the same page, handle the GET and POST request.

a. Inform the user where a GET or POST request was processed.

b. Display the content to the user

4. All POST and GET processing must be handled in PHP.

Part II: Sessions Your code needs to do the following:

1. Create a User object in a separate file.

2. Create an array of user objects in a separate file that contain the following users:

a. Johnny Test

i. username: tester ii. password: test

b. Sally Hooper

i. username: greater ii. password: tested

c. Arin Murrin

i. username: starter ii. password: westward

3. Create a login page with the following:

a. UserName b. Password c. Checkbox to remember username d. Login button e. Forget Me button

4. Checks for validation of the username and password using the array defined above.

i. If login is successful:

1. Redirect to another page using the session to pass the user object of the logged in user.

2. Display the name of the logged in user using the session to get the information.

a. Use the format LastName, FirstName (username).

ii. If not:

1. Inform the user it failed.

5. Have a way to log out that destroys the session from either page.

a. Redirect after login to a page showing that the username in the session has been cleared.

Note: you will need to include files as needed.