THE UNIVERSITY OF DODOMA

COLLEGE OF INFORMATICS AND VIRTUAL EDUCATION

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


NON-DEGREE UNIVERSITY EXAMINATIONS

FIRST SEMESTER 2019/2020


Course Code: CS 0219

Course Title: Internet Programming and Applications

Date: 17th February, 2020

Start: 11:45 AM

End: 14:45 PM

Time Allocated: 3 Hours


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

(4 Marks Each)


i. Write a PHP script to get the PHP version and configuration information.


ii. What is the difference between echo and print?


iii. What is the difference between require() and include()?


iv. What is the reason of writing at the beginning of an HTML page?


v. Which html tag is used to produce a horizontal line on a webpage?


Question Two

i. HTTP is a stateless protocol. Explain. [2 Marks]


ii. Explain the two ways of introducing state in HTTP protocol. [3 Marks]


iii. What is the difference between unset() and session_destroy() in php? [3 Marks]


iv. With the help of code segment explain the correct approach of using the setcookie() function. [3 Marks]

NB: You can use one example


v. Write a simple program to count the number of ā€˜hits’ on a webpage. [4 Marks]

NB: Choose one method that is suitable for you.


Question Three


i. What HTML tag is used to insert a copyright symbol in a web page? [3 Marks]


ii. How do we comment HTML code in an HTML page? [2 Marks]


iii. How do we comment PHP code in a PHP page? [2 Marks]


iv. What is the difference between POST method and GET method? [3 Marks]


v. What is the difference between _FILES[ā€˜user_file’][ā€˜tmp_name’]? [3 Marks]


vi. How can we capture an error during uploading files in php? [3 Marks]


vii. How can we change the maximum size of a file to be uploaded in PHP? [2 Marks]


Question Four

Examine the code in Figure 1, answer the following questions. [7 Marks]

Figure 1:

<!DOCTYPE html>
<html>
<head>
    <h1>Welcome to College of Informatics and Virtual Education</h1>
    <link src="mypage.css" type="text/css" rel="stylesheet"/>
</head>
<body>
    <p id="parg">For Department of computer science and Engineering</p>
    <ul>
        <li>BSc.In Computer Science</li>
        <li>BSc.In Software Engineering</li>
    </ul>
    For Department of Electronics and Telecommunication Engineering
    <ol>
        <li>BSc.In Telecommunication Engineering</li>
        <li>Diploma in Telecommunication</li>
        <li>Diploma in Computer Networks</li>
    </ol>
</body>
</html>

i. There are three (3) errors in the HTML code. Identify them and suggest corrections. [3 Marks]


ii. Write a CSS rule to set the page’s background to light blue. [2 Marks]


iii. Write CSS code to set the text color of list items to red. [2 Marks]


SECTION B (40 Marks)

Attempt ANY TWO questions from this section.


Question Five

Write a PHP code that processes the following form:

<fieldset>
    <legend>Registration Form</legend>
    <form action="abc.php" method="post" name="myForm">
        Name : <input type="text" name="name"><br>
        Password: <input type="text" name="password"><br>
        NIN: <input type="text" name="nin"><br>
        <input type="submit" name="submit" value="submit">
    </form>
</fieldset>

Your code should examine the name, password, and National Id Number (NIN) submitted, and verify that they are valid. A valid name is any non-empty string. A valid password is any string that is at least 6 characters long. A valid NIN contains exactly 24 digits. [20 Marks]


Question Six

Use Figure 1 in Question Four to answer the following questions:


i. Write a CSS rule that makes heading level one to be 36 large and color to be red. [3 Marks]


ii. Write a CSS rule that will change the background color of the page to be blue. [3 Marks]


iii. Write the CSS rule to place the image as a background color of the page. Assume the image is labeled ā€œcive.pngā€. [3 Marks]


iv. Write a CSS rule to make the background color of the paragraph yellow, arial, bold. [3 Marks]


v. How will the page look after adding the following CSS rule? [3 Marks]

* {
    color: green;
}

vi. Write a CSS rule to change the text color of the ordered list to be green. [5 Marks]


Question Seven

The following question use a database CS0219, table called users with the following structure: Assume the table already has some data inside.

CREATE TABLE users (
    RegNo VARCHAR(20) NOT NULL PRIMARY KEY,
    FirstName VARCHAR(20) NOT NULL,
    LastName VARCHAR(20) NOT NULL,
    Surname VARCHAR(20)
);

i. Write a code to make connection between PHP and Database. Servername=127.0.0.1, User=root, password="". [4 Marks]


ii. Write a PHP code to insert your details to the database (Your RegNo, first name, last name and surname). [4 Marks]


iii. Write a PHP code to retrieve all users in the database and display their details on the browser. [6 Marks]


iv. What is the importance of the Primary Key in the users table? [3 Marks]


END OF EXAMINATION PAPER