Web Design Lab Exercise Week 1
This exercise deals with basic forms handling in (X)HTML and PHP.
You will gain practice in using the POST method to send
user input to the server, and the print
function to display dynamic content to the end user.
Throught the course we will be following the content of Larry Ullman's
PHP for the Web very closely, and in several exercises you
will be using examples from the book as the basis for your web pages
and scripts. Before starting this exercise you may want to download
the complete set of examples from the companion website.
For this exercise you will find the examples from Chapter 3 particularly helpful,
and you may also need to look ahead to chapters 4 and 5. The online PHP manual
is the definitive reference source.
- Basic exercise: try out this very simple forms interface,
study the code and make sure you understand how it works,
especially the difference between single and double quotes.
You can see the PHP script here
Then write a version which says "What is your name?" above the text
input box, and replies with "Hello Fred" (or whatever name was entered).
- Intermediate: the form should ask for:
- title: Mr, Mrs, Ms, Dr or Prof from a drop-down menu;
- First name;
- Family name;
- Address.
The reply should look like:
"Hello, Mr Student Grant of Flat 17, 89 Gasworks Lane, Peckham".
Model answers:
HTML
PHP
- Advanced: the form should also include a field called
year of birth. The reply should be of the form:
"Hello, Mr Student Grant of Flat 17, 89 Gasworks Lane, Peckham.
You will be 27 this year."
Model answers:
HTML
PHP
- Optional: add CSS style sheets to the forms
and output pages to change the appearance according to your
preferences.