Department of Computing: CS-344: Web Engineering

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Department of Computing

CS-344: Web Engineering

Class: BESE-10AB

Lab 11: Multipage Dynamic Web Development Using PHP

Date: 09 Dec 2021

Instructor: Dr. Qaiser Riaz

CS-344: Web Engineering Page 1


Lab 11: Multipage Dynamic Web Development Using PHP

Introduction:
Students have learned the advanced concepts of PHP during lecture including CRUD operations
on a relational database management system, file handling, working with PHP super global
arrays such as $_SESSION, $_COOKIE etc. In this lab the students will get practical multipage
web development knowledge using the advanced PHP concepts.

Lab Objectives:
The objective of this lab is helping students to familiarize themselves with the usage of PHP to
create multipage dynamic websites by communicating with relational databases, working with
file upload/retrieval and display over a page, and using super global arrays such as $_SESSION
and $_COOKIE.

Tools:
Notepad, DreamWeaver, browser.

Helping Material:
Lecture slides.

W3Schools: https://www.w3schools.com/php/

PHP: www.php.net

Lab Task
Notes:

1. In the previous lab, you have already worked with the ‘classicmodels’ database. You
have to add a new column in the ‘employees’ table to store the path of the profile
picture of each employee. The name of the column should be ‘picPath’ and it should be
of type varchar (255).
2. Using phpMyAdmin, make sure that the ‘employees’ table is updated successfully and
you can see the new column.

Task 1
Extend the script you have created in the previous lab so that the employee’s picture is also
present in the table (in first column). To retrieve the picture, you have to find the path of the
picture from the ‘picPath’ column and then use this path in the ‘src’ attribute of the <img> tag.

CS-344: Web Engineering Page 2


Make sure to control the width and height of the picture in order to avoid distortion of the
table due to large image size. If the ‘picPath’ column is blank i.e., user has not uploaded his
profile picture, then display a default picture instead. The picture should be clickable and click
on it should open the edit page. Use your aesthetic sense to create beautiful tables using CSS.
An example is given below

Emp Office Reports


  Name Email Job Title Update
Address To
100 Market
Street, Suite Diane
Mary
mpatterso@classicmodelcars.com VP Sales 300, San Murphy, Edit | Update
Patterson
Francisco, President
  CA, USA

100 Market
Street, Suite Diane
VP
Jeff Firrelli jfirrelli@classicmodelcars.com 300, San Murphy, Edit | Update
Marketing
Francisco, President
  CA, USA

Task 2
Extend the create and update employee scripts so that user can upload his/her profile picture
when creating or updating an employee. Any new record or any change in the record (update)
must be saved in the database.

Important links for file handling in PHP:

https://www.w3schools.com/php/php_file_upload.asp

https://www.w3schools.com/php/php_file_create.asp

https://www.w3schools.com/php/php_file_open.asp

https://www.w3schools.com/php/php_file.asp

Task 3
Use super global arrays $_SESSION and $_COOKIE appropriately e.g. to store user’s information
in the session or to write cookies to store any important thing which can be useful in future.

CS-344: Web Engineering Page 3


Note: Upload complete solutions (css, html, js, php) for each task in a single zip and
screenshots of your solutions in this word file.

Solution
Task 1:

Task 1 screenshot:

Task 2:

Task 2 screenshot:

Task 3:

Task 3 screenshot:

Deliverables
Compile a single word document by filling in the solution part and submit this Word file on LMS.
You must include your name, ID, and class on first page. The lab grading policy is as follows: The
lab is graded between 0 to 10 marks. For some of the labs, students have to present their
solutions in a viva session. In case of any problems with submissions on LMS, you should
contact your lab engineer Ms. Ayesha Asif.

CS-344: Web Engineering Page 4

You might also like