CS案例之HTML、CSS、PHP网页相关MYSQL COMP284 Scripting La
当前位置:以往案例 > >CS案例之HTML、CSS、PHP网页相关MYSQL COMP284 Scripting La
2017-12-17


Your task for this practical project consists of two parts:

1. Develop a web-based system using HTML, CSS, PHP, and MySQL that provides the functionality stated in the Requirements section below.

2. Make the system that you have created accessible and usable via the URL

http://cgi.csc.liv.ac.uk/~/training.php

Take care that the access rights for the file are neither too restrictive nor too permissive. Making the system usable includes setting up the corresponding database on the departmental MySQL server and filling it with the appropriate data.

Requirements

A university offers a range of IT training sessions during welcome week that students can book in advance. The sessions cover topics such as Word Processing, Spreadsheets, etc. To keep the system simple, we assume that the students do not have computer accounts yet but instead enter a few personal details when they book a training session. Sessions on a particular topic are typically offered more than once during welcome week. Every time a session on a particular topic runs it can only accommodate a certain number of participants; in the following we will call this the capacity of the session. We keep the capacity of sessions small. Initially, the number of places left on a specific session is equal to its capacity.

In more detail, we assume that the University offers training sessions at the indicated times and all with the indicated capacity independent of the day of the week and time at which the session is offered:

Topic

Times

Capacity

Word Processing

Tuesday, 10:00; Wednesday, 11:00; Thursday, 12:00

4

Spreadsheets

Tuesday, 11:00, Wednesday, 12:00; Thursday, 10:00

3

Email

Tuesday, 12:00; Wednesday, 10:00; Thursday, 11:00

3

Presentation Software

Tuesday, 10:00; Thursday, 12:00

2

Library Use

Wednesday, 11:00

2

That is, in total there are sessions on 5 different topics, offered between once and three times during welcome week, with a capacity for only two to four participants every time a session on a particular topic runs.

The web-based system should allow a student to

1. select a topic via a drop-down menu;

2. select a day of the week and time at which a session on that topic is offered via a separate drop-down menu;

3. enter their name via a text field;

4. enter their e-mail address via another text field (in case the student needs to be contacted);

5. after selecting/entering the data above, submit a booking request by pressing a `Submit' button.

Ideally, a student is able to enter all this data via a single web page. Also, the menus are populated with data from the database.

On submission of a booking request, the user should be shown a response whether the booking request has been successful or unsuccessful. This response should include the details of the booking that was attempted.

· The system should ensure that what the user enters as a name satisfies the following constraints: A name is an arbitrary sequence of characters that only consists of letters (a-z and A-Z), hyphens, apostrophes and spaces; contains no sequence of two or more hyphens or two or more apostrophes; and starts with a letter or an apostrophe. If these constraints are satisfied, then we call the name valid. If these constraints are not satisfied, then the system should display an error message and the booking request must be unsuccessful.

· The system should ensure that what the student enters as e-mail address satisfied the following constraints: An e-mail address is an arbitrary sequence of characters that consists only of the characters a-z, A-Z, dot, hyphen plus exactly one occurrence of @. If these constraints are satisfied, then we call the e-mail address valid. If these constraints are not satisfied, then the system should display an error message and the booking request must be unsuccessful.

· If name and e-mail address are valid, then a booking request must be successful if the session on the selected topic at the selected day of the week and time still has at least one place left. On success, the number of places on the specified session is reduced by one and a record of the booking will be kept in the database, including which specific session was booked as well as the name and e-mail address of the student who booked the place.

· A booking request must be unsuccessful if there are no places left on the selected session.

Underlying the system must be a MySQL database. Initially, the database must contain information on the sessions, that is, the topic of each session, the day and time at which it runs, and its capacity, exactly as indicated in the table above. The database should then keep track of the number of places left after each successful booking request and also keep records of all successful bookings. The PHP Data Objects (PDO) extension of PHP must be used to implement the interactions between your system and the database.

Additional requirements and comments:

· If none of the sessions has places left, then the system should inform the user about this and not show any drop-down menus or text fields.

· The description of the system above suggests that a student goes through a sequence of five steps in order to submit a booking request. Your system should make sure that a request is only processed once all the required information has been provided and should produce appropriate error messages if the request does not contain all the necessary data.

· The system would ideally help a student by listing in the first menu only topics for which there are sessions with places left and, once the user has selected a particular topic in that menu, would in the second menu only list the days of the week and times at which sessions on the topic run that have places left.

· It would also be helpful if entries in the two menus are listed in a `sensible' order, that is, topics should be ordered alphabetically and the days of the week and times chronologically. Also, each topic should only occur at most once in the first menu and each day of the week and time at most once in the second menu.

· If a booking request is unsuccessful, then it should be possible for the student to make another attempt with as little effort as possible. For example, if name and e-mail address were valid, but there were no places left on the selected session, then the system would ideally be programmed in such a way that there is no need to enter name and e-mail address again when the students selects an alternative session.

· Note that the user still has great freedom when it comes to entering a name. You need to make sure that name strings are correctly stored in the database.
You should also make sure that code injection is not possible via any of the inputs of the system.

· There is the possibility that two users nearly simultaneously try to book the last remaining place on a particular session.. Depending on how you implement the interaction with the database, this could lead to a situation in which your system determines for both users that there is still a place remaining and then records for both users that he/she has successfully booked that place. This is obviously an incorrect behaviour by the system and needs to be avoided. The booking request of exactly one of the two users must be successful and the booking request of the other has to be unsuccessful.

· As this is an project on PHP, the use of other scripting languages should be kept to a minimum. In particular, the use of JavaScript must be restricted to the pre-defined submit() function, as shown in Practical 5 (Exercise 3).

· Your code should follow the COMP284 Coding Standard. This includes pointing out which parts of your code have been developed with the help of on-line sources or textbooks and references for these sources.

Submission

Submit your HTML, CSS, PHP code and a dump of your MySQL database (as separate, individual files; not as part of an archive file) via the departmental submission system at https://sam.csc.liv.ac.uk/COMP/Submissions.pl?module=comp284 (COMP284-2: PHP). Do not forget to also set up the database on the departmental MySQL server, to make training.php accessible via the departmental web server, and to correctly connect the two.


在线提交订单