| af Martin Elsman, Arne John Glenstrup and Niels Hallenberg | last updated 7th February 2004 |
In this exercise you must construct a web based project market using PHP and MySQL. The main page of the market must list all the projects in the database (ignore the fact that the project topics in the screen shots concern a different programming language than PHP):
One must be able to create a project with a project text:
Furthermore, by supplying a password, it must be possible for the user to update the project text:
The problem set is comprised of four exercises:
As the first step of constructing a web based project market, you must
construct a data model for the system, i.e., a table. The table must
contain information about project title, project text and information
about project administration: name, email and password. Furthermore,
every project must be identified by a unique number (use primary key and
auto_increment). You must ensure (using
unique) that all projects have different titles.
You must also write code for inserting two projects into the table.
Save your data model and the data insertion code in the file
H:public_html/w2/ps9/project.sql on ITU's web server.
In this exercise you must write valid transactions for the web based project market using SQL commands:
Save your SQL commands in a file
H:public_html/w2/ps9/transactions.sql on ITU's web server.
You must now design the structure of the web based project market. Here is a draft of what it should look like:
The boxes in the diagram represent the states of the web based project market for which HTML code is displayed in the user's browser. Unlabelled edges represent links to a new state, and labelled edges represent transactions where the database is updated (cf. exercise B) and the user sees the change in the browser by being sent to a new state.
The main page for the web based project market is shown as a box at the top of the diagram. The main page and the page for updating a project must be implemented as PHP scripts, because what is displayed in these pages depends upon the contents of the database and possibly form variables. The box for creating a new project can be implemented as an HTML file.
You must name the HTML and PHP files. To make it easier to find your
answers, the main page must be implemented in the file
H:public_html/w2/ps9/projects.php on ITU's web
server.
The purpose of this exercise is not to construct PHP scripts for the service, but to design the naming of the files that make up the service, and to determine which form variables should be transferred from one page to the next.
You must construct a description of your web structure containing
names of the PHP scripts that the project market consists of, and the
form variables each PHP script expects. You must either give the
description as a text file
H:public_html/w2/ps9/structure.txt, or as a figure
H:public_html/w2/ps9/structure.gif on ITU's web
server. If you supply a figure, each PHP script must be named and the
form variables it expects must be indicated.
In this exercise you must construct the HTML and PHP files for the database transactions. Begin by constructing the HTML and PHP files for the boxes in the diagram.
When implementing the PHP file for updating a project, you must remember to include code for comparing the entered password with the password in the database—naturally, it must only be possible for the administrator to change the project text!
Don't forget to validate the form variables.
Additional comments:
mydb.php and
formvars.php from the lectures.header:
header("Location:url")
This call returns a message to the browser instructing it to display the page with the given url.
Implement one or more of the following system extensions: