You are on page 1of 5

DIPLOMA IN COMPUTER SCIENCE DIPLOMA IN BUSINESS INFORMATION TECHNOLOGY FINAL EXAMINATION APRIL 2012

Course

: EC2308 (Internet Programming)

Time : Date :

3 hours

Lecturer : Ms. Suraiani Kassim

Instructions: The duration of the examination is 3 hours. Answer ALL questions in SECTION A. Answer any THREE (3) questions in SECTION B. Each question carries 25 marks.

The maximum number of marks is 100.

This question paper consists of 3 printed pages (excluding front cover)

DO NOT OPEN THIS BOOKLET UNTIL YOU ARE TOLD TO DO


SECTION A

Compulsory Question Question 1


a. Briefly describe the functions of a server-side script language.

(25 marks)

(4 marks) b. List and describe briefly FOUR (4) different types of server-side program scripts. (4 marks) Describe the THREE (3) main features of PHP. (6 marks) d. Produce the output for the following PHP code:

c.

i) <?php $cars[0]="Saab"; $cars[1]="Volvo"; $cars[2]="BMW"; $cars[3]="Toyota"; echo $cars[0] . " and " . $cars[1] . " are Swedish cars."; ?>
(3 marks)

ii) <?php $ages['Peter'] = "32"; $ages['Quagmire'] = "30"; $ages['Joe'] = "34"; echo "Peter is " . $ages['Peter'] . " years old."; ?>
(3 marks) ii)

<?php echo date("Y/m/d") . "<br />"; echo date("Y.m.d") . "<br />"; echo date("Y-m-d"); ?>
(5 marks)

SECTION B Answer any THREE (3) Questions From Question 2 to Question 5 marks) (75 1

Question 2
a. What is the difference between $_GET and $_POST method? (4 marks) b. Write a program code in PHP which accepts your name and age in a form by using the method $_POST , and display the information back to the web browser. (6 marks) Describe the include() function. (4 marks) d. Write a program code in PHP which must use the include() function to include the header file which we assume exists as header.php and your program. Then displays the following statement which is Hello and welcome to my Home Page on the web browser. You must note that you do not have to write the header.php code, but just include in the PHP program code only. (6 marks) What is the output for the program code below?

c.

e.

<html> <body> <?php $i=1; while($i<=5) { echo "The number is " . $i . "<br />"; $i++; } ?> </body> </html>
(5 marks)

Question 3
a. Describe the function statements and give an example of function declaration in PHP. (5 marks)

b.

Write a full PHP code which creates a list containing the costs and sales of five products. These two lists are to be defined as two arrays in the PHP code. Then you have to write the PHP code which calculates and prints the profit of each product. You have to use for loop in your source code. (10 marks) Write a full PHP code which declares the user-defined functions. These two functions calculate the area and circumference of a circle. In the main program the value of radius is set to 30. The results need to be displayed from the main program. The formula to calculate area is pi*r2 and for circumference is 2*pi*r. Pi needs to be declared as a global variable. (10 marks)

c.

Question 4
a. What is a database server? What is the advantage of using the database server? (2+2 marks) Write out the PHP commands to let the user connect to a database named as JOKES and to update the table ANYJOKES in that database. (9 marks) Write in PHP programming code for the problem below. For the input from the user, you have to include the form inside the PHP code. This program reads these data from the users. The input data are current day, current month, current year, your birth day, your birth month and birth year. You will have to calculate and display the age of the user, but in your calculation you will have to consider the current month and day to be compared with your birth month and birth day. (12 marks)

b.

c.

Question 5
a. What is session? (4 marks) b. Write the code to create a new session or resume an existing session. (6 marks) c. Write the built-in function to perform the following tasks: i. To set and get the name of the current session ii. To set and get the session ID of the current session iii. To destroy the current session (6 marks) d. What is cookie? (4 marks) e. Explain the syntax of the setcookie() below: setcookie(string name, string value, int expire)

(5 marks)

-THE END-

You might also like