BBT 2102 - Web Development - August 2019
BBT 2102 - Web Development - August 2019
BBT 2102 - Web Development - August 2019
Instructions
1. This examination consists of FIVE questions.
2. Answer Question ONE (COMPULSORY) and any other TWO questions.
Write the correct choice in your answer booklet. Each question is worth one mark.
1. Which is the correct way to link to an external stylesheet from a web page
a. <link rel = "stylesheet" type = "text/css" src = "styles.css" />
b. <link type=”stylesheet”>styles.css</link>
c. <link rel = "stylesheet" type = "text/css" href = "styles.css" />
d. <style href = "styles.css" type = "text/css" />
2. For the URL http://localhost/post.php?id=3 the script post.php can access the id as
a. $_SESSION[‘id’]
b. $_POST[‘id’]
c. $_GET[‘id’]
d. $id
3. The JavaScript method used to obtain a reference to an element that has its id attribute set is
a. getElementById()
b. document.element.getId()
c. document.getElementById()
d. getElementsByTagName()
4. In the code <a href=’www.google.com’>Google</a>
a. Google is content
b. a is an attribute
c. href is an element
Page 1 of 5
5. When a user places an order via the Web and posts the final “Confirm” form for the
purchase, the Web server should normally return HTML for the order confirmation page in the
response for the HTTP request..
a. True
b. False
6. Which JavaScript object is used to get data from a server in an AJAX transaction
a. navigator
b. ajaxObject
c. XMLHttpRequest
d. none of the above
7. To maintain state in a web application values can be set in
a. $_SESSION
b. $_REQUEST
c. $_GET
d. $_POST
8. In the PHP code given below, what is/are the properties?
< ?php
class Employee
{
public $name;
function welcome()
{
echo "Welcome ".$this->$name;
}
}
?>
a. echo "Welcome ".$this->$name;
b. function welcome()
c. Class Employee
d. public $name;
9. PHP recognizes constructors by the name.
a. classname()
b. _construct()
c. function _construct()
d. function __construct()
10. Suppose that an online retailer uses a relational database to keep track of orders, and one
table contains a row for each order. If an order contains several items, the foreign keys for each
of those items would typically be stored in the row for that order.
a. True
b. False
SECTION B: [20 marks]
a) Write a style rule for a div with an id of wrapper, which is used to layout a web page
1000px wide and 800px high with equal margins on the sides, and has a background
image called bg.jpg in a subdirectory called images. The image is the same size as the
div. (5 marks)
b) For the following code complete the function getPage() to load the URL associated with
the selected option. (5 marks)
<html>
<head>
Page 2 of 5
<title>Simple JavaScript Menu</title>
<script type="text/javascript">
function getPage(){
//your code here..
}
</script>
</head>
<body>
<form>
<select id="menu">
<option
value="https://www.google.com">Google</option>
<option
value="https://www.youtube.com">YouTube</option>
<option
value="https://www.twitter.com">Twitter</option>
</select>
<input type="button" value="Go" onclick = "getPage()"/>
</form>
</body>
</html>
c) Cascading Style Sheets is a style sheet language used for describing the presentation of
a document written in a markup language like HTML. Using relevant examples,
describe three ways that can be used to include CSS in a web page (6 marks)
d) Using examples, explain the two types of list elements in HTML (4 marks)
b) A login page has a form with fields for username and password. The names of these
text input fields are username and password respectively. Write a auth.php script that
checks to see if the posted username and password exists in the database. If the user
exists print Welcome <username> else print Incorrect username or password. The
users table is the one created in a) above. Hint: you should first connect to the database.
(10 marks)
Page 3 of 5
c) Using relevant code examples, discuss any four encryption algorithms that can be
implemented in a Php application. (8 marks)
Page 4 of 5
QUESTION FOUR [15 marks]
a) How many alert dialogs will the following Javascript generate, and what will be
displayed in each of them? (4 marks)
var x = "10";
function f(){
var x = "4";
alert(this.x);
function g(){
alert(x);
}
g();
}
f();
b) Label each of the tasks below with “Model”, “View”, or “Controller” to indicate where
that task would typically be implemented in a Web application using an MVC
architecture. (6 marks)
i. Validate form data
ii. Make sure a user is logged in
iii. Return a “redirect” to the browser
iv. Define an event handler for a custom form element
v. Generate a new session token
vi. Create a “salt” for a password
c) Below you will see some snippets of HTML from a Web page. Fill in the body of the
Javascript function changeColor so that the color of the text changes in response to the
selection made in the menu. (5 marks)
<style type="text/css">
.a {color:red;}
.b {color:green;}
</style> ...
<div id="colorText">Select below to change the color of this text</div>
<select onchange="changeColor(this.value)">
<option value="a">Red</option>
<option value="b">Green</option>
</select>
<script type="text/javascript">
function changeColor(value) {
//your code here
}
</script>
Page 5 of 5