Skip navigation
University of Liverpool –
Department of Computer Science
Computer Science
University home
> Computer Science
> People
> Ullrich Hustadt
> COMP284
> Assignment 2 Re-sit
COMP284 Scripting Languages (2018-19) — Assignment 2 Re-sit: PHP
Your task for this assignment consists of two parts:
1. Develop a web-based system using HTML, 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://student.csc.liv.ac.uk/~
Requirements
The flight booking site MyFlight has asked you to develop a web-based system that allows customers to book flights to several destinations operated by various airlines using planes with varying capacity. To keep the system simple, we ignore the departure cities, the dates and times at which flights depart, and even the planes. We also keep the number of destinations and airlines low. In particular, we use the following data:
Destination
Airline
Capacity
Base Price
Ankara
Air Europe
3
£1000
Ankara
Icarus Airlines
2
£500
Bucharest
Air Europe
3
£800
Bucharest
Romanian Airways
2
£700
Melbourne
Oceanic Airlines
4
£3000
Melbourne
Trans Pacific Airlines
4
£2500
Warsaw
Air Europe
3
£500
Warsaw
Uneasy Jet
2
£600
That is, there are 4 destination each served by two airlines. A flight is the combination of a destination and an airline. Each flight has a certain capacity, indicated in the table, which determines how many empty seats there initially are on that flight.
MyFlight operates an interesting pricing policy. To compute the price P that a customer is charged for a flight, it takes the base price B shown above and subtracts the number of seats S still empty on that flight times £100, that is, P = B – (S * £100). For example, if a customer wants to fly to Melbourne with Oceanic Airlines and there are still 2 out 4 seats empty, then the price will be P = £3000 – 2 * £100 = £2800.
A booking via the web-based system must proceed as follows:
1. The user can select a destination via a drop-down/pop-up list or selection menu;
2. The user can then select an airline that offers flights to the destination selected in Step 1;
3. The system shows the user the destination selected in Step 1 and the airline selected in Step 2 as well as the price calculated using MyFlight’s pricing policy;
4. The user can enter their e-mail address via a text field;
5. The user can then submit a booking request by pressing a `Submit’ button.
6. The system attempts to process the booking request and informs the user whether the request has been successful or not.
The process described above involves several HTTP requests and responses to those. Ideally, the requests would all use the Request-URL stated above, that is, the user interacts with a single PHP script that produces different output as the booking process progresses. However, a sequence of different Request-URLs / PHP scripts can be used if this is the only way that you can realise this system. Also, ideally, the menus are populated with data from the database.
On submission of a booking request, the user should be shown a message whether the booking request has been successful or unsuccessful. This message should include all the details of the booking that was attempted (destination, airline, price, e-mail address). This is subject to the following conditions:
• The system should ensure that the string entered by the user as an e-mail address has exactly one occurrence of @ that is preceded and followed by a non-empty sequence of the characters a-z, A-Z, dot, hyphen. An e-mail address that satisfies this constraint is called valid and the check that the user has entered a valid e-mail address must be performed using PHP only. If the input of the user is not a valid e-mail address, then an error message should be shown and the booking request is unsuccessful.
• If the e-mail address entered by the user is valid, then a booking request must be successful if on the selected flight there are still empty seats. On success, the number of empty seats on the selected flight must be reduced by one and a record of the booking must be stored in the database. It is important that the price stored as part of this record is the price that was shown to the user, not a price that is calculated at the time the booking request is processed.
• A booking request must be unsuccessful if not all the required information, that is, destination, airlines and e-mail address has been provided by the user.
• A booking request must be unsuccessful if there are no empty seats on the selected flight.
Underlying the system must be a MySQL database. Initially, the database must contain information on the destination, airlines, planes, their capacity, and number of empty seats. The database should then keep track of the number of empty seats remaining after each successful booking requests. The database should also keep a record of each successful booking, that is, store the destination, airline, plane, the e-mail address of the user, and the price that will be charged. 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:
• The description of the system above suggests that a user goes through a sequence of steps in order to submit a booking request. However, it might be possible for the user to skip some or all steps before clicking on the `Submit’ button. Your system should make sure that a request is only processed once the `Submit’ button has been pressed and should produce appropriate error messages if the request does not contain all the necessary data. But no error messages should be shown before clicking on the `Submit’ button.
• If all flights to all destinations are full, then the system should inform the user that there are currently no flights that can be booked and it should not show any menus or text fields.
• The menus should be populated with data from the database and entries in the two menus should be in alphabetical order.
• The system should help the user by only listing in the first menu those destinations for which there are flights that have empty seats. Once the user has selected a particular destination, then in the second menu only those airlines should be listed that have a flight with empty seats to that destination.
• If a booking request is unsuccessful, then it should then be possible for the user to make another attempt with as little effort as possible. For example, if the e-mail address was valid, but there were no empty seats on the selected flight, then the system would ideally be programmed in such a way that there is no need to enter the e-mail address again.
• One should expect that all `inputs’ to the system, even those that are intended to come from a menu, will be used by malicious users to inject code that causes your system to malfunction or reveal the contents of the database. You should program the system in a way that safeguards against such attacks.
• There is the possibility that two users nearly simultaneously try to book the last remaining empty seat on a flight. 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 an empty seat remaining and then records for both users that he/she has successfully booked that seat. This is obviously an incorrect behaviour by the system and needs to be avoided. (In reality, airlines do intentionally overbook their flights, but we do not want to do that.) The booking request of exactly one of the two users must be successful and the booking request of the other must be unsuccessful.
• As this is an assignment on PHP, the use of other scripting languages must be kept to a minimum. In particular, only the use of the existing JavaScript function submit() is allowed.
• Your code should be properly laid out and properly commented. 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. For further guidance see the COMP284 Coding Standard.
Each of these requirements is linked to one of more of the assessment criteria for this assignment. Therefore, the more requirements a system satisfies, the higher the mark.
Submission and Setup
Submit your HTML/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-21: PHP). You also need to set up the database on the departmental MySQL server, make courses.php and any auxiliary files usable via the departmental web server, and correctly connect the two.
The files submitted must be identical to those set up on the departmental web server. Furthermore, no alterations are allowed to the latter after files have been submitted. If a submitted file and the corresponding file on the departmental web server have different timestamps, then the later timestamp will be used to determine lateness. This applies even if the earlier file is used for marking.
Permissions of the files in your filestore must be such that no other user can view their contents in the filestore.
Deadline
The deadline for this assignment is
Friday, 9 August 2019, 17:00
Earlier submission is possible, but any submission after the deadline attracts the standard lateness penalties. Please remember that a strict interpretation of `lateness’ is applied by the Department, that is, a submission on Friday, 9 August 2017, 17:01 is considered to be a day late (analogously for submissions that are delayed further).
Assessment
This assignment addresses the following learning outcomes of the module:
• rapidly develop simple applications, both computer and web-based, using an appropriate scripting language;
• document and comment applications written using a scripting language.
This assignment contributes 30% to the overall mark of COMP284. Failure on this assignment may be compensated by higher marks on other assignments for this module.
Marks will be awarded according to the following scheme:
• Submission, setup, error-freeness: 10
• Input/Output handling: 36
• Database and database operations: 30
• Correctness of processing: 12
• Formatting, commenting, and quality of code: 12
In more detail, the requirements above translate into about 30 criteria that your system and its underlying code / database must satisfy. Marks are given according to the extent to which the system is observed to satisfy these criteria. Code that has no observable effect will typically receive no marks.
For a submission that is not set up correctly on the departmental web server and MySQL only the first and last item of the marking scheme will be assessed.
As stated above, the University policy on late submissions applies to this assignment, as do the University policy on coursework submission (available at https://www.liverpool.ac.uk/media/livacuk/tqsd/code-of-practice-on-assessment/appendix_Q_cop_assess.pdf) and the University policy on academic integrity (available at http://www.liv.ac.uk/student-administration/student-administration-centre/policies-procedures/academic-integrity/). You should follow the COMP284 Lab Rules to ensure that you do not breach the latter policy.
Department of Computer Science, University of Liverpool
Ashton Building, Ashton Street, Liverpool L69 3BX, United Kingdom
+44 (0)151 795 4275
Maintained by Ullrich Hustadt, u.hustadt@liverpool.ac.uk
© University of Liverpool – a member of The Russell Group
Departmental Contacts | University Contacts | Map | Legal | Accessibility