NAME: MOSES IKECHUKWU ASONYE
REG NUMBER: KPT/ODFEL/CST/24/003
DATE: 5TH AUGUST 2025
COURSE: COM 411
Question 1.
HTML Registration Form
User Registration Form
A PHP script that processes the form, hashes the password, and inserts the data into a MySQL
table using MySQLi and prepared statements.
Database and Table
User Registration Form
Database registered
Question 2: HTML + PHP Login Page
Login Page
Localhost
User info from Session
Question 3:
Understanding Object-Oriented Programming (OOP) in PHP
Object-Oriented Programming (OOP) is a programming paradigm based that revolves around the concept
of objects and classes. It allows developers to create reusable code, model real-world entities, and build
complex systems more efficiently.
Concepts of OOPP in PHP
1. Class : A class is a blueprint for an object. It defines properties and methods (functions) that objects
created from the class will have.
PHP Example:
class Car {
public $color;
public function __construct($color) {
$this->color = $color;
2. Object: Object is an instance of a class. It represents a real-world entity that has properties and
methods.
PHP Example:
$myCar = new Car ("Red");
3. Encapsulation
Encapsulation is the concept of bundling data and methods that operate on the data, restricting direct
access to some components.
PHP Example:
class BankAccount {
private $balance;
public function deposit($amount) {
$this->balance += $amount;
public function getBalance() {
return $this->balance;
4. Abstraction: Abstraction is the concept of hiding complex implementation details and showing only
essential features of an object or system.
PHP Example:
abstract class Vehicle {
abstract public function move();
class Car extends Vehicle {
public function move() {
echo "Car is driving.";
5. Inheritance: Is a concept where a child class (subclass) inherits properties and methods from a parent
class (superclass). This can also be said as creating a new class based on an existing class.
PHP Example:
class Animal {
public function eat() {
echo "Eating...";
class Dog extends Animal {
public function bark() {
echo "Barking.";
}
6. Polymorphism: Is a concept where methods can do different things based on the object they're called
upon, even if the method name is the same.
PHP Example:
interface Shape {
public function area();
class Circle implements Shape {
private $radius;
public function __construct($radius) {
$this->radius = $radius;
public function area() {
return 3.14 * pow($this->radius, 2);
class Rectangle implements Shape {
private $width, $height;
public function __construct($width, $height) {
$this->width = $width;
$this->height = $height;
public function area() {
return $this->width * $this->height;
}
7. Composition: Is the concept of combining objects to form a new object, where the contained objects
are not compete without the container.
PHP Example:
class Engine {
public function start() {
echo "Engine started.";
class Car {
private $engine;
public function __construct() {
$this->engine = new Engine();
public function start() {
$this->engine->start();
8. Interface: Is the contract that specifies a set of methods that must be implemented by any class that
implements it. An interface defines what methods are required, but not how they are implemented
PHP Example:
interface Printable {
public function print();
class Document implements Printable {
public function print() {
echo "Printing document.";
}
9. Trait: Is a reusable block of code that can be used in multiple classes, allowing for code reuse across
different classes. Traits are similar to classes, but cannot be instantiated on their own and are used to
provide a way to reuse code in multiple classes
PHP Example:
trait Logger {
public function log($message) {
echo "Logging: $message";
class User {
use Logger;
$user = new User();
$user->log("User logged in.");
10. Constructor: Is a special method that is automatically called when an object is created. It is used to
initialize the object’s properties and set up its initial state.
PHP Example:
class User {
public function __construct($name) {
echo "User $name created.";
new User("John");
11. Destructor: Is a special method that is automatically called when an object is destroyed or goes out
of scope. It is used to perform cleanup tasks, such as releasing resources or closing connections.
PHP Example:
class User {
public function __destruct() {
echo "User object destroyed.";
}
$user = new User();
unset($user);
Question 3: