Professional Documents
Culture Documents
Internet Programming
ICT2613
Semester 1
School of Computing
IMPORTANT NOTICE!!
Electronic communication with lecturers must be done through a myLife email account.
Always state the module and your student number in communication.
Note that ICT2613 is a fully online-presented course. No course material is posted to students.
When study material is uploaded on myUnisa in Additional Resources, you will be informed via
an e-mail to your myLife account.
Tutorial 101 contains some important information about the module. Software for the module is
available on Osprey website, http://osprey.unisa.ac.za/download/Disk/
This module will provide an intermediate web-developer with the knowledge to analyse contents
and problems, design, develop and maintain an appropriate web-based solution and skills to
supply solutions and with the values needed to develop an appreciation for a principled working
methodology within a changing society.
The student will be able to design and implement a new infrastructure in a web-based
environment.
Qualified students will able to design, develop and maintain web-sites and provide long term
principled decisions in a changing society to specific international standards of precision,
robustness, reliability, cost-effectiveness, solution-specific within a specified time-frame and
client-satisfaction.
Students will be able to analyse, design and develop appropriate web-based solutions in a
changing environment.
2.2 Outcomes
Specific outcome 1
Demonstrate an understanding of basic program operations in a web-based/internet
environment.
Range
Input/Output, basic arithmetic operations, logical operations, saving code
Assessment criteria
Code that requests input and produces output is written for a web-based / internet environment;
the use of operators to perform calculations and make logical decision is applied in such a way
that correct output is produced; demonstration includes the saving of work and retrieval.
Specific outcome 2
Demonstrate an understanding of and utilize the web-based / internet environment..
Range
Toolbox, Object properties, Objects, Toolbars, Events, Methods, Design window and code
window.
Assessment criteria
Code that contains the range elements is used. How it all forms part of an application to solve
a problem is explained and implemented logically.
Specific outcome 3
Demonstrate an understanding of and use variables in a web-based / internet e n v i r o n m e n t .
Range
Variable t y p e s , s c o p e , c o n s t a n t s , c o n v e r s i o n
Assessment criteria
Types of variables and how they may be manipulated are explained; when and from which
parts of the code variables are accessible are explained; the use of constants is demonstrated
and the motivations for using them are explained; the conversion of one type to another is
demonstrated and why it is useful is explained.
Specific outcome 4
Demonstrate an understanding of structures and their use in a web-based/internet environment.
Range
Loops decision making, arrays, repetition, functions
Assessment criteria
Code that involves structures is demonstrated to show how these structures are use in
decision making repetitions and variable structures.
Specific outcome 5
Demonstrate an understanding of and use basic exception handling in a web-based / internet
environment.
Range
Catch exception. Provide a way to handle the exception while code keeps running.
Assessment criteria
The student demonstrates in code how an exception is captured. The demonstration also
includes code to deal with the exception to prevent a program from halting.
Lecturer: Dr Anitta Thomas, thomaa@unisa.ac.za, 011 670 9181, C03-40, C Block, The Science
Campus, Cnr Pioneer and Christian de Wet streets, Florida Park, Roodepoort.
Note: E-mail is the preferred mode of communication. You can expect a reply to your e-mail
within 48 working hours.
E-tutor: You will receive an e-mail with the details of your e-tutor when an e-tutor is allocated to
you.
3.3 University
3.4 Forum
We will use myUnisa discussion forum this semester. Please participate in the forum.
3.5 Telephone
However, we request that you rather use the forum for c o u r s e content/presentation queries.
Send an email when you have queries outside the course content/presentation, e.g. a personal
issue. Either way, a traceable electronic record of your query is available.
3.6 E-mail
You must use your myLife e-mail account to send e-mails to the lecturer. Please provide the
module code in the subject line.
4.2 Software
4.3 S t u d y material
5 TEXTBOOK APPROACH
The prescribed handbook teaches all the skills you need to develop almost any type of database-
driven web site with PHP and MySQL.
The content is presented in "paired pages" (see screenshot below) with the essential syntax,
guidelines, and examples on the right page and the perspective and extra explanation on the left
page. The in-chapter exercises on the right-hand side are used to explain and illuminate the
theory which is presented on the left-hand pages. In this manner you add code to an in-chapter
exercise application as you progress through the chapter.
The code and solutions to most of the exercises/applications are made available. The intention
is for you to try and complete the exercises/applications on your own, and when you can’t do so,
you can refer to the solutions.
This is a programming module and thus, it is vital to practice programming on a computer with
the necessary software. The textbook and the assignments give sufficient programming
experience.
5 SOFTWARE
Step 1: Install server environment, editor and course files.
within the “Security” options). Failure to unblock the documentation file may result in error
messages including “Navigation to the webpage was canceled” due to Windows security
restrictions.
1. Refer to the folder TextbookResources in the link on Osprey for the course files (book
applications and source code)
2. For every chapter, read the text presented on the left page, and where applicable,
run/adapt the code presented on the right page (in-chapter exercises), which, if you have
followed the steps in the book appendix, is available in the books_app folder in your root
web folder.
3. Complete the exercises presented at the end of each chapter. Starting code is available in
the ex_starts folder.
4. The solutions to all these exercises are available in the ex_solutions folder. This
implies that you can simply copy the solutions and run them, or just read through them -
but as stated earlier, you should use the solutions to learn. Thus, try and complete an
exercise on your own, and only use the solution when you get stuck. If you do not follow
this route, you will not learn to program.
6 ASSIGNMENTS
Question 1
1. phpMyAdmin
2. MySQL
3. Apache
4. htdocs
Question 2
1. client-server application
2. database application
3. client-side application
4. server-side application
Question 3
All of the following except one are examples of web browsers. Which of the following is not a web
browser?
1. Chrome
2. Oracle
3. Internet explorer
4. Firefox
Question 4
1. .asp
2. .php
3. .htm
4. .pl
Question 5
To deploy a PHP application on your own computer, you copy the application root directory to the
______________.
1. htdocs directory of the MySQL server
2. htdocs directory of the Apache server
3. xampp directory of the Apache server
4. xampp directory of the MySQL server
Question 6
1. define(-TAX-, 14);
2. define($TAX, 14);
3. define('TAX', 14);
4. define($tax, 14);
Question 7
1. $var = 1;
2. $var = TRUE;
3. $var = "TEST";
4. $var = array();
Question 8
1. $result = 6 + 2 * 2;
2. $result = 2 + 2 + 1 * 2;
3. $result = 10 % 2 * 2;
4. $result = 11 - 1 / 2;
Question 9
$num = 0;
if($num < 0)
$num *= -1;
else
$num += 1;
What is the value of $num after the execution of the above lines of code?
1. -1
2. 0
3. 1
4. 2
Question 10
$count = 1;
while($count <= 5){
echo $count + ($count-1);
$count ++;
}
1. 12345
2. 1021324354
3. 1357
4. 13579
Question 11
1. PRIMARY
2. FOREIGN
3. INT
4. INDEX
Question 12
All the statements except one are true about relational databases. Choose the incorrect
statement regarding relational databases:
1. UPDATE
2. CREATE
3. INSERT
4. SELECT
Question 14
Which of the following statements is correct about the SQL statement given below?
1. The maximum number of rows that the result set can have is three
2. The result set has rows from the table invoices
3. The maximum number of columns that the result set can have is two
4. The result set has rows sorted in descending order of vendorID
Question 15
1. INNER JOIN
2. WHERE BY
3. FROM THE
4. BY ORDER
Question 16
Question 17
Question 18
Question 19
Study the database table named weather given below, where record_number is the primary
key:
Which one of the following options will result in $result storing the following result?
Gordons Bay,12
Johannesburg,25
Hammanskral,7
Mamelodi,1
Port Elizabeth,3
Assume that a PDO object named $db is correctly connected to the relevant database.
1.
$query = 'SELECT place, rainfall FROM weather';
$statement = $db->prepare($query);
$statement->execute();
$records = $statement->fetchAll();
$statement->closeCursor();
$result = "";
foreach($records as $record){
$result = $result. $record[1]. "," . $record[3]. "<br>";
}
2.
$query = 'SELECT * FROM weather';
$statement = $db->prepare($query);
$statement->execute();
$records = $statement->fetchAll();
$statement->closeCursor();
$result = "";
foreach($records as $record){
$result = $result. $record[1]. "," . $record[3]. "<br>";
}
3.
$query = 'SELECT * FROM weather';
$statement->execute();
$records = $statement->fetchAll();
$statement->closeCursor();
$result = "";
foreach($records as $record){
$result = $result. $record[1]. "," . $record[3]. "<br>";
}
4.
$query = 'SELECT place, rainfall FROM weather';
$statement = $db->prepare($query);
$records = $statement->fetchAll();
$statement->closeCursor();
$result = "";
foreach($records as $record){
$result = $result. $record['place']. "," .
$record['rainfall']. "<br>";
}
Question 20
Study the database table named weather given below, where record_number is the primary
key:
$date = '2019-12-27';
$rainfall = 25;
$statement = $db->prepare($query);
$statement ->bindValue(':rec_no', $rec_no);
$statement ->bindValue(':place', $place);
$statement ->bindValue(':date', $date);
$statement ->bindValue(':rainfall', $rainfall);
$statement->execute();
$statement->closeCursor();
Assume that a PDO object named $db is correctly connected to the relevant database.
1.
record_number place date rainfall
1 Gordons Bay 2019-03-01 12
2 Johannesburg 2019-01-30 25
3 Hammanskral 2019-04-12 7
4 Mamelodi 2019-06-23 1
5 Roodepoort 2019-12-27 25
2.
record_number place date rainfall
1 Gordons Bay 2019-03-01 12
2 Johannesburg 2019-01-30 25
3 Hammanskral 2019-04-12 7
4 Mamelodi 2019-06-23 1
5 Port Elizabeth 2019-10-19 3
5 Roodepoort 2019-12-27 25
3.
record_number place date rainfall
1 Gordons Bay 2019-03-01 12
2 Johannesburg 2019-01-30 25
3 Hammanskral 2019-04-12 7
4 Mamelodi 2019-06-23 1
5 Port Elizabeth 2019-10-19 3
4.
record_number place date rainfall
1 Gordons Bay 2019-03-01 12
2 Johannesburg 2019-01-30 25
3 Hammanskral 2019-04-12 7
4 Mamelodi 2019-06-23 1
5 Port Elizabeth 2019-10-19 3
6 Roodepoort 2019-12-27 25
Question 21
When you use the MVC pattern, the model consists of the PHP files that work with and represent
the ________________ of the application.
1. verifier
2. view
3. central processing unit
4. data
Question 22
Question 23
When you code a function in PHP, you start with the ________________ keyword.
1. class
2. method
3. return
4. function
Question 24
When you use the MVC pattern, the ________________ consists of the HTML and PHP files that
make up the user interface of the application.
1. model
2. view
3. controller
4. module
Question 25
Which type of statement should be included if a function must send a value back to where the
function was called?
1. send
2. parameter
3. return
4. argument
Question 26
An error that lets the application run but produces the wrong results is known as a _________.
1. runtime error
2. logic error
3. user error
4. syntax error
Question 27
1. misspelling keywords
2. using a keyword as a variable name
3. multiplying by the wrong variable
4. forgetting a closing quotation mark
Question 28
The purpose of the code is to decide whether a string is long or short. A string is considered short
if its length is less than or equal to 20 characters. If the length of a string is greater than 20
characters, then it considered a long sentence.
Which line of the code has an error in satisfying the above-mentioned purpose?
1. line 6
2. line 5
3. line 4
4. line 3
Question 29
Question 30
Select the odd one in the context of testing and debugging PHP code:
1. breakpoints
2. stack trace
3. adding echo statements in the code to inspect variables during execution
4. chrome
Assignment 2 (chapters 6-12)
Question 1
How many radio buttons can be selected at any given time from the following code?
<input type="radio" name="address" value="Home">Home Address
<input type="radio" name="delivery" value="FedEx">Federal Express
<input type="radio" name="delivery" value="UPS">UPS
1. 1
2. 2
3. 3
4. 4
Question 2
A hidden field _____________.
Question 3
All of the input options except one allows user to indicate a choice or choices – select this odd
one.
1. list box
2. drop-down box
3. checkboxes
4. text area
Question 4
Which method would be typically used if a form contains password fields or other sensitive data
that you don’t want to display in the URL?
1. GET
2. ACTION
3. APPEND
4. POST
Question 5
Study the code below:
Question 6
What does $message contain after the following code executes?
$age = 19;
$score = 750;
1. Loan approved.
2. Cosigner needed.
3. Two cosigners needed.
4. Loan denied.
Question 7
All the statements are correct except one about the OR (||) operator. Choose the incorrect
statement.
1. It returns a TRUE value when the expressions on both sides of the operator returns FALSE
values
2. It returns a TRUE value when the expression on the left hand side of the operator returns a
TRUE value
3. It returns a TRUE value when the expression on the right hand side of the operator returns a
TRUE value
4. It is a logical operator.
Question 8
Which type of loop will always execute its code at least once?
1. for
2. while
3. do while
4. foreach
Question 9
1. ++
2. !
3. &&
4. <=
Question 10
$statusCode = "203";
switch($statusCode) {
case "200":
$message = "OK";
break;
case "403":
$message = "Forbidden";
break;
case "404":
$message = "Not Found";
break;
default:
$message = "Unknown Status";
break;
}
1. OK
2. Forbidden
3. Not Found
4. Unknown Status
Question 11
What is stored in $result after the execution of the lines of code below?
$result = "limpopo";
$result = ucfirst($result);
str_replace("o", "*", $result);
1. limpopo
2. Limpopo
3. limp*p*
4. Limp*p*
Question 12
Which one of the following is incorrect about working with times and dates in PHP?
Question 13
1. chars()
2. length()
3. count()
4. strlen()
Question 14
Suppose that $name contains a last name followed by a comma and a space, followed by a first
name. Then, you can store the first and last names in variables with code like this:
Question 15
1. 20 20
2. 2020
3. 20202020
4. 2020 2020
Question 16
If the date is 25 August 2020, what output would be produced by the code below?
1. 25 8 2020
2. 25 august 2020
3. 25 Aug 20
4. 25 08 20
Question 18
1. After the execution of this code $d1 will store 1 May 2020
2. After the execution of this code $d1 will store 27 May 2020
3. Line 2 has a syntax error relating to the use of modify()
4. The DateTime object is created with an incorrect date in line 1
Question 19
Question 20
Which method of a DateTime object can be used to determine an amount of time between two
dates or times?
1. diff()
2. datebetween()
3. datediff()
4. add()
Question 21
In the following options, there are three valid ways to declare and initialize arrays. Choose the
invalid way of declaring and initializing an array.
1.
$anArray = array();
$anArray[] = 1;
$anArray[] = 2;
$anArray[] = 3;
2.
$anArray = array( , , );
3.
$anArray = array();
$anArray[1] = 1;
$anArray[3] = 2;
$anArray[4] = 3;
4.
$anArray = array(1,2,3);
Question 22
$anArray = array(0,1);
for($n = 0; $n <= 5; $n++){
$anArray[] = $anArray[$n] + $anArray[$n+1];
}
1. 0, 1
2. 0, 1, 2, 3, 4, 5
3. 0, 1, 2, 3, 4, 5, 8
4. 0, 1, 1, 2, 3, 5, 8, 13
Question 23
$anArray = array("A" => "Afrikaans", "S" => "Sepedi", "Z" => "Zulu");
1. 1
2. 2
3. 3
4. 6
Question 24
1. Leopard
2. Rhino
3. Elephant
4. Buffalo
Question 25
Question 26
Question 27
Question 28
setcookie("cookie_1", "1");
1. The statement is syntactically incorrect as the function needs at least four arguments
2. The cookie set by this statement is a persistent cookie
3. If a PHP file containing this statement is executed on the local host, this cookie will be stored in
the same directory in the htdocs directory where the PHP file is stored.
4. When executed, this statement creates a cookie with the information cookie_1 = 1
Question 29
1. $name
2. $value
3. $method
4. $expire
Question 30
1. session_name
2. SESSIONID
3. SESSIONCOOKIE
4. PHPSESSID
9 EXAMINATIONS
An exam letter will be distributed towards the end of the semester.
10 APPENDIX
INSTALLING WAMPSERVER
You either install WampServer or XAMPP. Please do not install both. If you choose WampServer
instead of XAMPP, given below are the installation instructions.
Step 1
Note:
Before proceeding with the installation of WampServer, you must ensure that the run-time
environments here below are installed on your system, otherwise WampServer will absolutely not
run. In addition, the installation will be faulty and you will need to remove WampServer before
installing the elements that were missing. Make therefore sure you are "up to date" in the
redistributable packages VC9, VC10, VC11, VC13 and VC14 as listed here under.
Install the following 5 run-time environments (VC9 to VC14) from the software, or download them
from the link provided (if you have a 64-bit Windows, you must install both the 32 and 64bit
versions).
c) VC11 Packages (Visual C++ 2012 Update 4) The two files VSU4\vcredist_x86.exe and
VSU4\vcredist_x64.exe to be download are on the same page:
d) VC13 Packages] (Visual C++ 2013[) The two files VSU4\vcredist_x86.exe and
VSU4\vcredist_x64.exe to be download are on the same page:
e) VC14 Packages (Visual C++ 2015) The two files vcredist_x86.exe and vcredist_x64.exe to
be download are on the same page:
Step 2
USING WAMPSERVER
manage (start and stop) your Apache and MySQL services (mostly used)
switch online/offline (give access to everyone or only localhost)
install and switch Apache, MySQL and PHP releases (not required)
manage your servers settings (in case of port clashes with Skype)
access your error logs
access your settings files
©
Unisa 2021