"); } else { $mime_type = "text/html"; header("Content-type: $mime_type; charset=utf-8"); } ?>
For this assignment, you are to add a form element containing an assortment of form-related elements to your web page.
This assignment is very loosely structured: the goal is for you to become familiar with forms, but there is not enough time for you realistically to do a full-blown form design assignment before the end of the semester.
The minimum structure of the assignment is for you to display a form on the web page that requires visitors to “log in” by supplying a user name and a password. If you have time to do more, you can turn the “log in” form into a “register” form that uses various additional form elements to supply additional information besides a user name and password.
A second requirement is to use your CSS skills to style the form so that looks good and is well positioned on the page.
I am providing you with the following PHP code that you are to add to your web page to control the content based on whether the form has been submitted to it or not. (This concept will be covered in class.)
Copy and paste the above code into your index.xhtml file just before the first paragraph (p) element in the #content div. It’s very important that the second to last line (EOD;) starts with the 'E' in the leftmost character position of the line because of the way PHP implements the else echo <<<EOD statment three lines above it.
The form element is already in the PHP code: all you need to do is to add the code for the elements inside the form. The first part of the code generates a table that will show the name and value of each item of form data when the form is submitted.
That is, when you insert this code into your web page, the #content div will start with either a form or a table, depending on whether the form has been submitted yet or not. Seeing the page in action in class should make this mechanism a bit clearer.
Forms are covered in Chapter 9 of the textbook, so consult that if any of the following material is not clear. Here are the elements and their attributes that you will need to add to the form to implement the login feature:
You will also need to provide an id for this element for use with its label. (See next item.)
To associate a label with an input element, you have to use the for attribute in the label, and the value of the for attribute has to match the value of the id attribute of the corresponding input element.
You will probably have an easier time using CSS to manage the layout of your form if you put the labels before their corresponding input elements.
Be sure the name attribute for the password is both meaningful and different from the name attribute for the user field.
This screenshot of a form might help you follow the above description (right-click to view larger size):
The optional version of the form would use multiple text inputs for name, address, etc., and could use checkboxes and/or radio buttons so the user could express preferences, past experience, etc. Be creative!
When you are ready for me to look at your assignment, simply send me an email message to let me know. I’ll manually copy your entire web site to my computer (babbage) and check it out. The full pathname to your web site on babbage will be http://babbage.cs.qc.cuny.edu/Grading/cs081/ followed by your account name.
Send your email message to me at: vickeryatbabbage.cs.qc.cuny.edu by midnight of the due date.
The Subject line of your email message must be: “CS-081 Assignment 10.”
Don’t forget to put your name in your email message!