Web Programming

CSC 240
Union College
Fall 2009


Homework 6 is online.

Homework 3

Topic: PHP
Due date: Thursday, October 1st


In this assignment you will build a small web site that allows people to fill in a web form and uses the supplied information to generate a letter. (Think, for example, about a letter enquiring about the availability of a hotel room: the number of people, the dates and other desired properties of the hotel room would be supplied by the user through the form.)

Part 0

Pick a theme for your web site.

Part 1

Find 5-10 pictures that relate to the theme of your web site, and create a web page that uses PHP to randomly pick one of the pictures and display it. (To make it a little bit more interesting, this will become part of the visual design of your web site.)

Hint: Create an array containing the file names of the pictures. Then use the built-in function rand to randomly pick one of the array elements. You can get the size of an array using the built-in function count.

Design and implement the structure for your page (using XHTML and CSS). Integrate your random pictures into it, and reserve some space for the form that you will implement in the rest of this assignment. For example, your layout could look like this:

Part 2

Make a copy of your documents and code from Part 1. Add a form to the content area of your page that asks the user for at least 4 pieces of information. Label the form fields so that the user knows what to enter. Submitting the form should cause the server to execute a PHP file. The PHP script should write the field names and values of the form elements into an array. Then use the foreach loop to write the list items and display them (in the content area of your page).

Part 3

Make a copy of your documents and code from Part 2 and change the form tag so that it sends its field values to a new PHP document. This document should write a short form letter with at least 3 of the form field values inserted into the text. Write and use a PHP function that takes these field values as parameters and displays the form letter as a web page.

Part 4

Create an "index" page with links to the pages for parts 1, 2 and 3 above.

Publish the pages in your account on antipasto so that the URL of the index page is "http://antipasto.union.edu/~username/csc240/hw/hw3".

Turn in