0% found this document useful (0 votes)
70 views

ITU07427 - Lab Worksheet

This document provides a lab worksheet on developing web-based applications using PHP and MySQL. It outlines 27 practical questions to help students learn how to configure web and database servers, develop web applications using tools and techniques like PHP, apply security, connect PHP to MySQL, and use sessions. The questions cover topics like PHP basics, control structures, functions and arrays, SQL, and more. References for further reading are also provided.

Uploaded by

Burhan ENT
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views

ITU07427 - Lab Worksheet

This document provides a lab worksheet on developing web-based applications using PHP and MySQL. It outlines 27 practical questions to help students learn how to configure web and database servers, develop web applications using tools and techniques like PHP, apply security, connect PHP to MySQL, and use sessions. The questions cover topics like PHP basics, control structures, functions and arrays, SQL, and more. References for further reading are also provided.

Uploaded by

Burhan ENT
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

INSTITUTE OF ACCOUNTANCY ARUSHA

DEPARTMENT OF INFORMATICS

ITU07427/ECU07426: INTERNET PROGRAMMING AND APPLICATIONS

LAB WORKSHEET

Introduction
This lab is intended to equip students with programming principles for developing web-
based applications.

Competency Aimed (Enabling Learning Outcome)

• Apply computer programming principles in implementing web-based applications

Specific Objectives (Sub-Enabling Learning Outcomes)

(i) Use web techniques in configuring a web server and database server

(ii) Use appropriate tools and techniques in developing a web-based application

(iii) Apply security techniques in a web-based application

References

• Lecture handouts

• Deitel, H. M. & Deitel, P. J. (2011). Internet & World Wide Web: How to Program.
5th Ed. Upper Saddle River, NJ: Pearson Education

• Welling, L. & Thomson, L. (2016). PHP and MySQL Web Development. 5th Ed.
Boston, MA: Addison-Wesley Professional
• Cross, M. (2011). Developer's Guide to Web Application Security. Rockland, MA:

Page 1 of 7
Syngress Publishing, Inc.

• Grove, R.F. (2009). Web-Based Application Development. Burlington, MA: Jones


& Bartlett Publishers

• Wandschneider, M. (2006). Core Web Application Development with PHP and


MySQL. Upper Saddle River, NJ: Prentice Hall

• Sriparasa, S. S. (2014). Building a Web Application with PHP and MariaDB: A


Reference Guide. Birmingham: Packt Publishing

Practical Questions
Topics: Introduction to PHP and PHP Operators

1. Modify the PHP first script so that the script displays the string “Welcome to
Advanced Web Design” in a web browser.

2. Write a PHP script which calculates and displays the sum of two numbers in a
web browser.

3. Write a PHP script that calculates and prints the area and perimeter of a
rectangle in a web browser.

4. Write a PHP script that outputs “My name is $name” where $name is a variable
that stores your actual name.

5. What will be the output of the following PHP code?

<?php
$num = 10;
echo 'What is her age? \n She is $num years old;
?>
6. Write a PHP script named area.php that calculates and displays an area of a
circle in a web browser.

Page 2 of 7
7. Write a PHP script that obtains two numbers from a user, calculates the sum of
these numbers and displays the result in a web browser [Note: A script requires
HTML/PHP form].

Topic: Control statements


8. Write a PHP script that displays “This is a positive number” in a web browser if
and only if the number is positive.

9. Write a PHP script that accepts two numbers, divides the first number by the
second number and prints the result in a web browser.

10. Write a PHP script that asks the user to enter two numbers, obtains the numbers
from the user, and then prints in a web browser the larger number followed by
the words “is larger.” If the numbers are equal, print the message “These
numbers are equal.”

11. Write a PHP script that inputs three different numbers from the keyboard, then
prints the sum, the average, the product, the smallest and the largest of these
numbers in a web browser.

12. Use Table 1 which shows numerical score ranges and their respective grades to
write a PHP script that checks the student’s score and prints the student’s grade
in a web browser.

Table 1: Numerical Score and Grade for Students

Score (Marks in Grade


percentage)

81 – 100 A

61 – 80 B

41 – 60 C

21 – 40 D

Page 3 of 7
0 – 20 F

13. What will be the output of the following PHP code?

<?php
$team = "manu";
switch ($team) {
case "manu":
echo "I love Manchester United";
break;
case "arsenal":
echo "I love Arsenal";
break;
case "manc":
echo "I love Manchester City";
break;
default:
echo "I do not like football at all";
}
?>

14. Write a PHP script that displays even numbers between 1 and 100 inclusive in a
web browser.

15. Write a PHP script that calculates the sum of the first 200 counting integers and
displays the result in a web browser.

16. Write a PHP script that calculates the squares and cubes of the numbers from 0
to 10 and uses tabs to print the following table of values in Figure 1:

Page 4 of 7
Figure 1: Table of values

Topics: Functions and arrays


17. Write a PHP script that contains function area for calculating the area and
function perimeter for calculating the perimeter of a rectangle and displays the
result in a web browser

18. Define a function area which calculates the area of the circle. Call the function
and display the area calculated by the function in a web browser.

19. Write a PHP script that accepts input of two numbers. The script contains
function add for performing the addition of two numbers; function subtract for
performing subtraction of the second number from the first number; function
multiply for performing multiplication of the two numbers and function divide for
performing division of two numbers. The script should also give the user an
option of performing one of the operations above and displaying the result in a
web browser.

20. Given the array, $fruits = array (“apple", "orange", "banana"), write a PHP script
that displays all the array elements of the array $fruits in a web browser.

21. Write a PHP script that calculates the sum and average of all array elements,
$numbers=array (4, 8, 16, 32, 64) and prints the sum and average in a web
browser.

Topic: SQL
22. The university database consists of two tables – student and user. The student
table consists of four columns that stand for each student’s registration number,

Page 5 of 7
full name, department and date of birth. Write SQL statements to perform the
following activities:

(a) Create university database


(b) Create student table
(c) Insert data into the student table
(d) Display all student details where full names are sorted in alphabetical
order
(e) Display students from the Informatics department
(f) List all students whose full names start with the letter A

23. The company database consists of six tables – employee, department,


department_locations, project, works_on and dependent. The employee table
consists of six columns that stand for each employee’s first name, middle name
initial, last name, social security number, address and department number. The
department table consists of four columns that stand for each department’s
name, number, manager social security number and manager start date. Write
SQL statements to perform the following queries:

(a) Retrieve the list of all employees and their respective departments
(b) Retrieve the birth date and address of the employee(s) whose name is
‘John B. Smith’.
(c) Retrieve the name and address of all employees who work for the
‘Research’ department.
(d) Select all EMPLOYEE Ssns
(e) Select all combinations of EMPLOYEE Ssn and DEPARTMENT Dname in
the database.
(f) Retrieve the total number of employees in the company
(g) Retrieve the total number of employees in the ‘Research’ department
(h) For each department, retrieve the department number and the number of
employees in the department.

Page 6 of 7
Topics: Connecting PHP to MySQL, and Sessions
24. Write a PHP script that retrieves data from the student table of the university
database as shown in Figure 2.

Figure 2: Sample data from the student table

25. Write a PHP script that obtains a URL and its description from a user and stores
the information in a database using MySQL. Create and run a SQL script with a
database named URL and a table named Urltable. The first field of the table
should contain an actual URL, and the second, which is named Description,
should contain a description of the URL. Use www.deitel.com as the first URL,
and input Cool site! as its description. The second URL should be www.php.net,
and the description should be The official PHP site. After each new URL is
submitted, print the contents of the database in a table.

26. Write a PHP script that creates session variables and uses them to authenticate
a user to log into a web-based information system using a username and
password.

27. Write a PHP script that destroys session variables in question 26.

Page 7 of 7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy