THE UNIVERSITY OF DODOMA

COLLEGE OF INFORMATICS AND VIRTUAL EDUCATION

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


UNDERGRADUATE UNIVERSITY EXAMINATIONS

FIRST SEMESTER 2019/2020


Course Code: CS 312

Course Title: INTERNET PROGRAMMING AND APPLICATIONS

Date: 17th February, 2020

Time Allocated: 3 Hours

Start: 11:45 AM

End: 14:45 PM


INSTRUCTIONS:

  1. This question paper consists of two sections: A and B
  2. Answer ALL questions in section A and ANY Two questions from section B
  3. All University of Dodoma Examination Regulations Apply

SECTION A: (60 Marks)

Question One

Choose the correct answer for each of the following questions. (1 Mark Each)


I. 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 rel="stylesheet" type="text/css" href="styles.css">

C. <style href="styles.css" type="text/css">

D. <style div{color:blue;} </style>


II. JavaScript is generally used as: -

A. a client-side scripting language

B. a server-side scripting language

C. an application development language

D. an embedded language for mobile devices


III. Which JavaScript function is used to open a small window for user input: -

A. alert()

B. prompt()

C. document.write()

D. init()


IV. Which property of a page element (eg a div) is used by JavaScript to alter the content of a page after it has loaded: -

A. value

B. text

C. firstChild

D. innerHTML


V. 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


VI. The JavaScript method used to obtain a reference to an element that has its id attribute set is: -

A. getElementById()

B. element.getId()

C. document.getElementById()

D. getElementByTagName()


VII. Which function is used to place the content of another file into a web page?

A. place()

B. insert()

C. select()

D. include()


VIII. To maintain state in a web application values can be set in:-

A. $_SESSION

B. $_REQUEST

C. $_GLOBALS

D. $_POST


IX. A form has a text field: <input type="text" name="phone"/> When the form is submitted to a processing script, the text in this field can be found as the value of the variable:-

A. $_SESSION[‘name’]

B. $_POST[‘phone’]

C. $name

D. $phone


X. Which is not true of an XML document?

A. It must have a root element

B. It must have a Schema approved by the W3C

C. All tags must be properly closed

D. The values of any attributes may be written in single quotes


Question Two

When dealing with files uploaded through HTTP, PHP stores references of them in the super global array. These files must be processed or moved from their temporary location during the lifetime of the PHP script execution or they will be automatically deleted. Write a PHP script to upload a file to a server. (10 Marks)


Question Three

Make a web page that uses a cookie to keep track of how many times a user has viewed the page. The first time a user views the page, it should print “Number of views: 1.” The second time the user looks at the page, it should print “Number of views: 2,” and so on. [10 Marks]


Question Four

I. Write a CSS rule that changes the color of all elements containing attribute id=“Green-Move” to green and shift them down 25 pixels and right 15 pixels. [5 Marks]


II. Write a layout template that contains two columns. Use divs for each layout component, and use float to line up the columns side by side. Give each component a border and/ or a background color so you can see where your divs are. [5 Marks]


III. Several divs have a class of even. Write a style rule (as it would appear in an external stylesheet) that gives each of these black text on a red background using 14px sans-serif font, and the borders should be 1 pixel solid black lines all around. [5 Marks]


IV. Write an SQL script to create a table called users in a database, with the following fields (assume the specific database has already been accessed) id, which is the primary key and value is provided by the database server. username, which has an appropriate string format. password, with a format specific for the SHA encryption algorithm. reg_date, with an appropriate date format. [5 Marks]


V. Which PHP functions are used to achieve the following with a MySQL database server on the local machine. [2.5 Marks Each]

a. Connect to the server with username root and password carrot2go

b. Select a database called ad006 to be used for queries


SECTION B (40 Marks)

Attempt ANY TWO questions from this section.


Question Five

The University of Dodoma has asked you to create a program that allows prospective students to provide feedback about their campus visit. Your program should contain a form with text boxes for a name, address and email. Provide checkboxes that allow prospective students to indicate what they liked most about the campus. The checkboxes should include: student, location, campus, atmosphere, dorm rooms and sports. Also, provide radio buttons that ask the prospective student how they became interested in the University. Provide radio buttons with the following options: Friends, Television, Internet and Other. Finally, provide a text area for additional comments, a submit button and a reset button. Write a complete HTML document for the feedback form and a PHP script to process the form and display the submitted data. [20 Marks]


Question Six

I. Write a PHP script to get the PHP version and configuration information [2 Marks]


II. What is the difference between echo and print? [2 Marks]


III. Describe the differences between client/server interactions in traditional web applications and client/server interactions in Ajax web applications. [5 Marks]


IV. Modules are helpful for many sites that include sections of repeated code. Explain the following three functions, make the differences between them clear: include(), require(), require_once(). [5 Marks]


V. Consider the following associative array

<?php
$ManUarray = array(
    "Rashford" => 23,
    "Pogba" => 24,
    "Degea" => 22,
    "Martial" => 25
);
?>

a. Write PHP code to add a new element with the key “Wan-Bisaka” and value 24. [3 Marks]

b. Write PHP code to remove the element with the key “Pogba”. [3 Marks]


END OF EXAMINATION PAPER