ExamBank Scot · AH Computing Science question bank · All AH Computing Science questions
15 marks · HTML forms and form data
Tours can be booked using the online form shown below. Tour Booking Form Full Name*: Contact Number*: Date of tour*: Time*: 09:00am 10:00am 11:00am 12:00pm Reset Submit * identifies a field which must be completed The first three lines of HTML code used to generate the form are shown below. Line 1 <h2>Tour Booking Form</h2> Line 2 <form ________________________________________ > Line 3 Full Name*:<input type="text" name="fullName" required> Once completed, the form data will be submitted securely to the server-side script called form1.php. Complete Line 2 of the HTML code used to create this form. A relational database is used to store details of tours and tour guides. The SQL code used to create the Guide table is shown below. CREATE TABLE Guide( guideID int NOT NULL PRIMARY KEY, lastName varchar(20) NOT NULL, firstName varchar(20) NOT NULL ); The data submitted by the HTML form is stored in a second table called Tour. This table has a field called tourID which uses auto increment. The relationship between the Tour and Guide tables is shown below. M 1 Tour Guide Write the SQL code to create the Tour table. The managing director wants to know the largest number of tours completed by any of the tour guides on 16/04/2019. Write the SQL statement to display the number of tours each tour guide completed on 16/04/2019. Write the SQL statement, using your answer from (c) (i), to display the largest number of tours completed. When a request for a tour is received, the date and time selected is checked against existing tours. The algorithm used to check the available date and time is shown below. 1. assign full name submitted to $fullname 2. assign contact number submitted to $contact 3. assign date submitted to $date 4. assign time submitted to $time 5. select a tour guide and assign ID to $guideID 6. assign connection details (server = ice1, username = u1, password = p1, database = facilityTour) 7. connect to secure database 8. if requested date and time is available 9. add tour details to Tour table 10. else 11. display message indicating different date/time must be selected. 12. end if Write the server-side script required to implement Line 6 and Line 7 of the algorithm. Write the server-side script required to implement Line 9 of the algorithm. The number of tours is lower than the management of the company would like. They consider using social media and online marketing to improve this. Describe one legal concern management may have in using these approaches. An ice cream company offers tours of its production facility.
<FORM action="form1.php" method="post"> 1 mark for action 1 mark for method CREATE TABLE Tour (tourID int AUTO_INCREMENT PRIMARY KEY; fullName varchar(20) NOT NULL; contactNo varchar(11) NOT NULL; tripDate date NOT NULL; tripTime time NOT NULL; guideID int; FOREIGN KEY (guideID) REFERENCES Guide(guideID) ); 1 mark for primary key with auto increment and correct data type 1 mark for additional 5 fields with correct data types 1 mark for foreign key guideID SELECT guideID AS [Guide ID], COUNT(*) AS [Number of Tours] FROM Tour WHERE tripDate = "16/04/2019" GROUP BY guideID; 1 mark for correct fields with WHERE clause 1 mark for correct use of COUNT and correct grouping Note: field names should match those introduced in the CREATE statement in part (b) Note: use of aliases is not mandatory SELECT MAX([Number of Tours]) FROM ci; 1 mark for use of MAX 1 mark for correct use made of (c)(i) query 6.1 $servername="ice1"; 6.2 $username="u1"; 6.3 $password="p1"; 6.4 $database="facilityTour" ; 7.1 $conn = mysqli_connect ($servername, $username, $password, $database); 1 mark for assignment of data values to connection variables 1 mark for connection code Note: accept mysqli_connect without $conn variable $sql = "INSERT INTO Tour (fullName, contactNo, tripDate, tripTime, guideID) VALUES ($fullname, $contact, $date, $time, $guideID)"; mysqli_query($conn, $sql); 1 mark for INSERT query with values in same sequence as fields 1 mark for correct fields (tourID should not be listed) 1 mark for execution of query For example: • Need to gain the necessary agreement/consent of customers whose data is gathered – without this the company is in breach of GDPR • The company must own IPR all of media used in promotional materials – without this the company is in breach of Copyright, Design and Patents Act 1 mark for any valid concern
Previous question: AH Computing Science 2019 Question 1 (CfE)