You are on page 1of 24

Module 4: Basic CRUD Operations in PHP + MYSQL

Learning Outcomes:
At the end of the lesson, the students are able to:
 Find out what a Web database application is
 Discover how MySQL works
 Implement CRUD Operations using PHP
 Understand how PHP and MySQL work together
 Create a PHP Web Page with Database Connectivity

Discussions
Introduction
So you need to develop an interactive Web site. Perhaps your boss just put you in charge of the
company’s online product catalog. Or you want to develop your own Web business. Or your sister wants to
sell her paintings online. Or you volunteered to put up a Web site open only to members of your circus
acrobats’ association. Whatever your motivation might be, you can see that the application needs to store
information (such as information about products or member passwords), thus requiring a database. You can
see also that the application needs to interact dynamically with the user; for instance, the user selects a
product to view or enters membership information. This type of Web site is a Web database application.

What Is a Web Database Application?


Web based or Web application. If the Web application requires the long-term storage of information
using a database, it’s a Web database application. This module provides you with the information that you
need to develop a Web database application that can be accessed with Web browsers such as Chrome
Explorer and Firefox
A Web database application is designed to help a user accomplish a task. It can be a simple application
that displays information in a browser window (for example, current job openings when the user selects a job
title) or a complicated program with extended functionality (for example, the book ordering application at
Amazon.com or the bidding application at eBay).
A Web database application consists of just two pieces:
 Database: The database is the long-term memory of your Web database application. The
application can’t fulfill its purpose without the database. However, the database alone is not
enough.
 Application: The application piece is the program or group of programs that performs the
tasks. Programs create the display that the user sees in the browser window; they make your
application interactive by accepting and processing information that the user types in the
browser window; and they store information in the database and get information out of the
database

The database: Storing data


The core of a Web database application is the database, which is the long-term memory that stores
information for the application. A database is an electronic file cabinet that stores information in an organized
manner so that you can find it when you need it. After all, storing information is pointless if you can’t find it. A
database can be small, with a simple structure — for example, a database containing the titles and authors’
names of all the books that you own. Or a database can be huge, with an extremely complex structure — such
as the database that Amazon.com has to hold all its information.
The information that you store in the database comes in many varieties. A company’s online catalog
requires a database to store information about all the company’s products. A membership Web site requires a
database to store information about members. An employment Web site requires a database (or perhaps two
databases) to store information about job openings and information from résumés. The information that you
plan to store could be similar to information that’s stored by Web sites all over the Internet — or information
that’s unique to your application.
The term database refers to the file or group of files that holds the actual data. The data is accessed by
using a set of programs called a DBMS (Database Management System). Almost all DBMSs these days are
RDBMSs (Relational Database Management Systems), in which data is organized and stored in a set of related
tables

The application: Moving data in and out of the database


For a database to be useful, you need to be able to move data into and out of it. Programs are your tools
for this because they interact with the database to store and retrieve data. A program connects to the
database and makes a request: “Take this data and store it in the specified location.” Another program makes
the request: “Find the specified data and give it to me.” The application programs that interact with the
database run when the user interacts with the Web page. For instance, when the user clicks the submit button
after filling in a Web form, a program processes the information in the form and stores it in a database.

MySQL, My Database
MySQL is a fast, easy-to-use RDBMS used on many Web sites. Speed was the developers’ main focus from
the beginning. In the interest of speed, they made the decision to offer fewer features than their major
competitors (such as Oracle and Sybase). However, even though MySQL is less full-featured than its
commercial competitors, it has all the features needed by the majority of database developers. It’s easier to
install and use than its commercial competitors, and the difference in price is strongly in favor of MySQL
Advantages of MySQL
 It’s fast. The main goal of the folks who developed MySQL was speed. Thus, the software was
designed from the beginning with speed in mind.
 It’s inexpensive. MySQL is free under the open source GPL license, and the fee for a commercial
license is reasonable.
 It’s easy to use. You can build and interact with a MySQL database by using a few simple
statements in the SQL language, which is the standard language for communicating with
RDBMSs.
 It can run on many operating systems. MySQL runs on many operating systems — Windows,
Linux, Mac OS, most varieties of Unix (including Solaris and AIX), FreeBSD, OS/2, Irix, and
others.
 It’s available on almost all Web hosts. If you’re going to run your Web site on a Web hosting
company, MySQL is widely available without extra cost.
 Technical support is widely available. A large base of users provides free support through
mailing lists. The MySQL developers also participate in the e-mail lists.
 It’s secure. MySQL’s flexible system of authorization allows some or all database privileges
(such as the privilege to create a database or delete data) to specific users or groups of users.
Passwords are encrypted.
 It supports large databases. MySQL handles databases up to 50 million rows or more. The
default file size limit for a table is 4GB, but you can increase this (if your operating system can
handle it) to a theoretical limit of 8 million terabytes (TB).
 It’s customizable. The open source GPL license allows programmers to modify the MySQL
software to fit their own specific environments.

PHP, a Data Mover


PHP, a scripting language designed specifically for use on the Web, is your tool for creating dynamic Web
pages. Rich in features that make Web design and programming easier, PHP is in use on more than 20 million
domains (according to the Netcraft survey at www.php.net/usage.php). Its popularity continues to grow, so it
must be fulfilling its function pretty well.
PHP is particularly strong in its ability to interact with databases. It supports pretty much every
database you’ve ever heard of. PHP handles connecting to the database and communicating with it. You don’t
need to know the technical details for connecting to a database or for exchanging messages with it. You tell
PHP the name of the database and where it is, and PHP handles the details. It connects to the database, passes
your instructions to the database, and returns the database response to you.

MySQL and PHP, the Perfect Pair


MySQL and PHP as a pair have several advantages:
 They’re free. It’s hard to beat free for cost-effectiveness.
 They’re Web oriented. Both were designed specifically for use on Web sites. Both have a set of
features focused on building dynamic Web sites.
 They’re easy to use. Both were designed to get a Web site up quickly.
 They’re fast. Both were designed with speed as a major goal. Together they provide one of the
fastest ways to deliver dynamic Web pages to users.
 They communicate well with one another. PHP has built-in features for communicating with
MySQL. You don’t need to know the technical

How MySQL and PHP work together


PHP provides the application part, and MySQL provides the database part of a Web database application.
You use the PHP language to write the programs that perform the application tasks. PHP can be used for
simple tasks (such as displaying a Web page) or for complicated tasks (such as accepting and verifying data
that a user typed into an HTML form). One of the tasks that your application must do is move data into and
out of the database — and PHP has built-in features to use when writing programs that move data into and
out of a MySQL database.
PHP statements are embedded in your HTML files with PHP tags. When the task to be performed by the
application requires storing or retrieving data, you use specific PHP statements designed to interact with a
MySQL database. You use one PHP statement to connect to the correct database, telling PHP where the
database is located, its name, and the password needed to connect to it. The database doesn’t need to be on
the same machine as your Web site; PHP can communicate with a database across a network. You use another
PHP statement to send an SQL message to MySQL, giving MySQL instructions for the task you want to
accomplish. MySQL returns a status message that shows whether it successfully performed the task.

ACTIVITY 4.1 – BASIC CRUD OPERATIONS (PHP + MYSQL)


PC/Laptop Demo: https://youtu.be/UTYzrVvsqjU Mobile Demo: https://youtu.be/RWKGL3YtP1I
Instructions:
1. DESIGN THE DATABASE.
A. Using SQLYog or PHPMyAdmin. Create a database db_is301_initials.
B. Create the following tables.

tbluser

Field Name Data Type Len


UserID varchar 20
LastName varchar 50
FirstName varchar 50
MiddleName varchar 50
EmailAddress varchar 50
Password varchar 50

tblstudent
Field Name Data Type Len
StudentID varchar 20
LastName varchar 50
FirstName varchar 50
MiddleName varchar 50
Address varchar 200
Course varchar 50

CREATE TABLE `tbluser` (


`UserID` varchar(20) default NULL,
`LastName` varchar(50) default NULL,
`FirstName` varchar(50) default NULL,
`MiddleName` varchar(50) default NULL,
`EmailAddress` varchar(50) default NULL,
`Password` varchar(50) default NULL
);

CREATE TABLE `tblstudent` (


`StudentID` varchar(20) default NULL,
`LastName` varchar(50) default NULL,
`FirstName` varchar(50) default NULL,
`MiddleName` varchar(50) default NULL,
`Address` varchar(200) default NULL,
`Course` varchar(50) default NULL
);

2. Open your text editor Visual Studio Code or ACode.


3. Right click code-YearSection-initials in workspace >> Select New Folder >> Type module4-files
4. Right click module4-files in the workspace >> Select New Folder >> type act1-mod4-files
5. Right click module4-files in the workspace >> Create the following folders:
A. config
B. users
6. SETUP THE DATABASE CONNECTION
A. Right click config folder in the workspace >> Select New File >> Type database.php

B. Provide the following codes in database.php


<?php
//DATABASE CONNECTION STRING CREDENTIALS
$dbConn = "mysql:host=127.0.0.1;dbname=db_is301_initials";
$user = "root";
$pass = "123456"; //for mobile users password: root

//CREATE PDO DATABASE CONNECTION


$pdo = new PDO($dbConn, $user, $pass);
?>
7. SETUP THE CREATE (SAVE) METHOD
A. SETUP THE CREATE WEB FORM
i. Right click users folder in the workspace >> Select New File >> Type create-user-
form.html

ii. Provide the following codes in create-user-form.html


<!DOCTYPE html>
<html>
<head>
<title>Create New User</title>
</head>
<body>
<!--SETUP FORM METHOD POST AND CALL THE PHP SCRIPT TO CREATE THE
RECORD-->
<form name="frmUser" method="POST" enctype="" action="create-user-
rec.php">
<h2>Create User</h2>
<!--SETUP THE WEB FORM-->
<table>
<tr>
<td>User ID:</td>
<td><input type="text" name="txtID"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="txtLName"></td>
</tr>
<tr>
<td>First Name:</td>
<td><input type="text" name="txtFName"></td>
</tr>
<tr>
<td>Middle Name:</td>
<td><input type="text" name="txtMName"></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="txtEmail"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="txtPass"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="txtConfirm"></td>
</tr>
<tr>
<td><input type="submit" value="SUBMIT"><input type="reset"
value="RESET"></td>
<td><a href="read-all-user-form.php" target="_parent">Back to
List</a></td>
</tr>
</table>
</form>
</body>
</html>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/create-
user-form.html
iv. The output should look the image below:

B. SETUP THE CREATE PHP SCRIPT


i. Right click users folder in the workspace >> Select New File >> Type create-user-
rec.php

ii. Provide the following codes in create-user-rec.php


<?php
//CALL DATABASE CONNECTION SCRIPT
include("../config/database.php");

//GET USER INPUT FROM WEB FORM


$uid = $_POST['txtID'];
$lname = $_POST['txtLName'];
$fname = $_POST['txtFName'];
$mname = $_POST['txtMName'];
$email = $_POST['txtEmail'];
$pass = $_POST['txtPass'];

//CREATE QUERY TO INSERT RECORDS


$query = "INSERT INTO tbluser SET
UserID=:uid,
LastName=:lname,
FirstName=:fname,
MiddleName=:mname,
EmailAddress=:email,
Password=:pass";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//BIND PARAMETER VALUES


$stmt->bindParam(":uid", $uid);
$stmt->bindParam(":lname", $lname);
$stmt->bindParam(":fname", $fname);
$stmt->bindParam(":mname", $mname);
$stmt->bindParam(":email", $email);
$stmt->bindParam(":pass", $pass);

//EXECUTE STATEMENT
$stmt->execute();

//REDIRECT TO READ ALL USER WEB PAGE


header("location: read-all-user-form.php");
?>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/create-
user-form.html
iv. Fill-out the web form and Click SUBMIT Button. The output should look the image
below:

v. Open SQLYog and check the record in tblUser in the database.

8. SETUP THE READ (ALL) METHOD


A. SETUP THE READ ALL WEB FORM
i. Right click users folder in the workspace >> Select New File >> Type read-all-user-
form.php

ii. Provide the following codes in read-all-user-form.php


<!DOCTYPE html>
<html>
<head>
<title>User Management Records</title>
</head>
<body>
<form name="frmUserRec" method="POST" enctype="" action="">
<!--CREATE LINK TO OPEN CREATE USER WEB FORM-->
<h2>User Table | <a href="create-user-form.html">Create New
User</a></h2>
<table width="100%" border="1" cellspacing="5">
<tr>
<th>USER ID</th>
<th>LAST NAME</th>
<th>FIRST NAME</th>
<th>MIDDLE NAME</th>
<th>EMAIL ADDRESS</th>
<th colspan=3></th>
</tr>

<?php
error_reporting(0);
//CALL DATABASE CONNECTION SCRIPT
include("../config/database.php");

//CREATE THE QUERY TO SELECT ALL RECORDS FROM THE TABLE


$query="SELECT * FROM tbluser";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//EXECUTE STATEMENT
$stmt->execute();

//GET RECORDS PER ROW


$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

//LOOP AND STORE DATA RECORDS TO VARIABLES


foreach($rows as $row){
$uid = $row["UserID"];
$lname = $row["LastName"];
$fname = $row["FirstName"];
$mname = $row["MiddleName"];
$email = $row["EmailAddress"];

//DISPLAY RECORDS AS TABLE ROWS AND TABLE DATA


echo'
<tr>
<td>'.$uid.'</td>
<td>'.$lname.'</td>
<td>'.$fname.'</td>
<td>'.$mname.'</td>
<td>'.$email.'</td>
<td><a href="read-one-user-form.php?id='.$uid.'"
target="_parent">View Record</a></td>
<td><a href="update-user-form.php?id='.$uid.'" target="_parent">Edit
Record</a></td>
<td><a href="delete-user-form.php?id='.$uid.'"
target="_parent">Delete Record</a></td>
</tr>
';
}
?>
</table>
</form>
</body>
</html>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/read-all-
user-form.php
iv. The output should look the image below:

9. SETUP THE READ (ONE) METHOD


A. SETUP THE READ ONE WEB FORM
i. Right click users folder in the workspace >> Select New File >> Type read-one-user-
form.php

ii. Provide the following codes in read-one-user-form.php


<?php
//DISABLE ERROR DETECTION
error_reporting(0);

//CALL DATABASE CONNECTION SCRIPT


include("../config/database.php");

//CREATE THE QUERY TO SELECT ALL RECORDS FROM THE TABLE


$query="SELECT * FROM tbluser WHERE UserID=?";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//BIND VALUE TO DATABASE PARAMETER


$stmt->bindValue(1, $_GET[id]);

//EXECUTE STATEMENT
$stmt->execute();

//GET RECORDS PER ROW


$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

//LOOP AND STORE DATA RECORDS TO VARIABLES


foreach($rows as $row){
$uid = $row["UserID"];
$lname = $row["LastName"];
$fname = $row["FirstName"];
$mname = $row["MiddleName"];
$email = $row["EmailAddress"];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>View User Record</title>
</head>
<body>
<form name="frmUserRec" method="POST" enctype="" action="create-user-
rec.php">
<h2>View User Record</h2>
<table>
<?php
echo'
<tr>
<td>User ID:</td>
<td>'.$uid.'</td>
</tr>
<tr>
<td>Last Name:</td>
<td>'.$lname.'</td>
</tr>
<tr>
<td>First Name:</td>
<td>'.$fname.'</td>
</tr>
<tr>
<td>Middle Name:</td>
<td>'.$mname.'</td>
</tr>
<tr>
<td>Email Address:</td>
<td>'.$email.'</td>
</tr>
<tr>
<td><a href="read-all-user-form.php" target="_parent">Back to
List</a></td>
<td><a href="update-user-form.php?id='.$uid.'"
target="_parent">Update Record</a></td>
</tr>';
?>
</table>
</form>
</body>
</html>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/read-all-
user-form.php
iv. Click View Record Link. The output should look the image below:

v. Click Back To List. The output should look the image below:

10. SETUP THE UPDATE (EDIT) METHOD


A. SETUP THE UPDATE RECORD WEB FORM
i. Right click users folder in the workspace >> Select New File >> Type update-user-
form.php

ii. Provide the following codes in update-user-form.php


<?php
//DISABLE ERROR DETECTION
error_reporting(0);

//CALL DATABASE CONNECTION SCRIPT


include("../config/database.php");
//CREATE THE QUERY TO SELECT ALL RECORDS FROM THE TABLE
$query="SELECT * FROM tbluser WHERE UserID=?";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//BIND VALUE TO DATABASE PARAMETER


$stmt->bindValue(1, $_GET[id]);

//EXECUTE STATEMENT
$stmt->execute();

//GET RECORDS PER ROW


$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);

//LOOP AND STORE DATA RECORDS TO VARIABLES


foreach($rows as $row){
$uid = $row["UserID"];
$lname = $row["LastName"];
$fname = $row["FirstName"];
$mname = $row["MiddleName"];
$email = $row["EmailAddress"];
$pass = $row["Password"];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Update User Record</title>
</head>
<body>
<form name="frmUserRec" method="POST" enctype="" action="update-user-
rec.php">
<h2>Update Record</h2>
<table>
<tr>
<td>User ID:</td>
<td><input type="text" name="txtID" value="<?php echo $uid; ?>"></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type="text" name="txtLName" value="<?php echo $lname; ?
>"></td>
</tr>
<tr>
<td>First Name:</td>
<td><input type="text" name="txtFName" value="<?php echo $fname; ?
>"></td>
</tr>
<tr>
<td>Middle Name:</td>
<td><input type="text" name="txtMName" value="<?php echo $mname; ?
>"></td>
</tr>
<tr>
<td>Email Address:</td>
<td><input type="text" name="txtEmail" value="<?php echo $email; ?
>"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="txtPass" value="<?php echo $pass; ?
>"></td>
</tr>
<tr>
<td>Confirm Password:</td>
<td><input type="password" name="txtConfirm" value="<?php echo
$pass; ?>"></td>
</tr>
<tr>
<td><input type="submit" value="SUBMIT"></td>
<td><a href="read-all-user-form.php" target="_parent">Back to
List</a></td>
</tr>
</table>
</form>
</body>
</html>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/read-all-
user-form.php
iv. Click Edit Record Link. The output should look the image below:

B. SETUP THE UPDATE RECORD PHP SCRIPT


i. Right click users folder in the workspace >> Select New File >> Type update-user-
rec.php

ii. Provide the following codes in update-user-rec.php


<?php
//CALL DATABASE CONNECTION SCRIPT
include("../config/database.php");

//GET USER INPUT FROM WEB FORM


$uid = $_POST['txtID'];
$lname = $_POST['txtLName'];
$fname = $_POST['txtFName'];
$mname = $_POST['txtMName'];
$email = $_POST['txtEmail'];
$pass = $_POST['txtPass'];
//CREATE QUERY TO INSERT RECORDS
$query = "UPDATE tbluser SET
LastName=:lname,
FirstName=:fname,
MiddleName=:mname,
EmailAddress=:email,
Password=:pass
WHERE UserID=:uid";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//BIND PARAMETER VALUES


$stmt->bindParam(":uid", $uid);
$stmt->bindParam(":lname", $lname);
$stmt->bindParam(":fname", $fname);
$stmt->bindParam(":mname", $mname);
$stmt->bindParam(":email", $email);
$stmt->bindParam(":pass", $pass);

//EXECUTE STATEMENT
$stmt->execute();

//REDIRECT TO READ ALL USER WEB PAGE


header("location: read-all-user-form.php");
?>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/read-all-
user-form.php
iv. Click Edit Record Link and update the data. Click SUBMIT Button. The output should
look the image below:
v. Open SQLYog and check the updated record in tblUser in the database.
11. SETUP THE DELETE METHOD
A. SETUP THE DELETE RECORD WEB FORM
i. Right click users folder in the workspace >> Select New File >> Type delete-user-
form.php

ii. Provide the following codes in delete-user-form.php


<?php
//DISABLE ERROR DETECTION
error_reporting(0);

//CALL DATABASE CONNECTION SCRIPT


include("../config/database.php");

//CREATE THE QUERY TO SELECT ALL RECORDS FROM THE TABLE


$query="SELECT * FROM tbluser WHERE UserID=?";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//BIND VALUE TO DATABASE PARAMETER


$stmt->bindValue(1, $_GET[id]);

//EXECUTE STATEMENT
$stmt->execute();

//GET RECORDS PER ROW


$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
//LOOP AND STORE DATA RECORDS TO VARIABLES
foreach($rows as $row){
$uid = $row["UserID"];
$lname = $row["LastName"];
$fname = $row["FirstName"];
$mname = $row["MiddleName"];
$email = $row["EmailAddress"];
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Delete User Record</title>
</head>
<body>
<form name="frmUserRec" method="POST" enctype="" action="">
<h2>Delete User Record</h2>
<table>
<?php
echo'
<tr>
<td>User ID:</td>
<td>'.$uid.'</td>
</tr>
<tr>
<td>Last Name:</td>
<td>'.$lname.'</td>
</tr>
<tr>
<td>First Name:</td>
<td>'.$fname.'</td>
</tr>
<tr>
<td>Middle Name:</td>
<td>'.$mname.'</td>
</tr>
<tr>
<td>Email Address:</td>
<td>'.$email.'</td>
</tr>
<tr>
<td><a href="read-all-user-form.php" target="_parent">Back to
List</a></td>
<td><a href="delete-user-rec.php?id='.$uid.'" target="_parent">Delete
Record</a></td>
</tr>';
?>
</table>
</form>
</body>
</html>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/read-all-
user-form.php
iv. Click Delete Record Link. The output should look the image below:

B. SETUP THE DELETE RECORD PHP SCRIPT


i. Right click users folder in the workspace >> Select New File >> Type delete-user-
rec.php

ii. Provide the following codes in delete-user-rec.php

<?php
//DISABLE ERROR DETECTION
error_reporting(0);

//CALL DATABASE CONNECTION SCRIPT


include("../config/database.php");

//CREATE THE QUERY TO SELECT ALL RECORDS FROM THE TABLE


$query="DELETE FROM tbluser WHERE UserID=?";

//PREPARE QUERY AND STORE TO A STATEMENT VARIABLE


$stmt = $pdo->prepare($query);

//BIND VALUE TO DATABASE PARAMETER


$stmt->bindValue(1, $_GET[id]);

//EXECUTE STATEMENT
$stmt->execute();

//REDIRECT TO READ ALL USER WEB PAGE


header("location: read-all-user-form.php");
?>
iii. Start xampp or AWebServer >> Open a web browser provide the url >>
http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-files/users/read-all-
user-form.php
iv. The output should look the image below:
v. Click Delete Record Link and Open SQLYog and check if the record was deleted in
tblUser in the database.

12. CHECK HYPERLINKS


A. CREATE FORM HYPERLINK
i. Open form http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-
files/users/create-user-form.html
ii. Click Back To List Link. User Table Form will be displayed.

B. READ ALL FORM HYPERLINK


i. Open form http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-
files/users/read-all-user-form.html
ii. Click Create New User Link. Create User Form will be displayed.

C. READ ONE FORM HYPERLINK


i. Open form http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-
files/users/read-all-user-form.html
ii. Click View Record Link. View User Record will be displayed.
a. Click Back To List Link. User Table Form will be displayed.

b. Click Update Record Link. User Record Form will be displayed

D. DELETE RECORD FORM HYPERLINK


i. Open form http://localhost/is301-bsis2x-initials/module4-files/act1-mod4-
files/users/read-all-user-form.html
ii. Click Delete Record Link. Delete User Record Form will be displayed.
a. Click Back To List Link. User Table Form will be displayed.

13. PERFORM AND RECORD THE FOLLOWING ACTIONS:


A. Create four (4) records
B. View Two (2) records
C. Update Two (2) records
D. Delete Two (2) records

Notes:
 Use the machine problem worksheet provided in assignment section of the course in the
LMS and provide a screen shot of the codes.
 Using any screen recording software (Open Broadcaster Software, Bandicam or Filmora),
record the machine problem output demonstration.
 Submit the activity in the assignment section of the course in the LMS:
o PDF Format. Filename: ACT1-MOD4-IS301-INITIALS.
o YouTube link or URL of the recorded output demonstration.
 Five (5) points deductions will be given to each submission protocol violations:
o Not including initials in variable names, object names, class names, method
names and project names.
o Not using of activity and machine problem worksheets.
o Incorrect Filenames Format: ACTIVITY_TITLE_INITIALS.PDF
o Incomplete Source codes and output screenshots in PDF Format.
o Broken Links or no video demonstration outputs.

 Any similarities on the source codes or any sign of “Copy and Paste” codes will be
marked as CHEATING and will be graded ZERO (0).

You might also like