Course Title: Producing server-side script for dynamic
web pages
Unit One: Web Documents Requiring Server-
Side Dynamic Interaction
Unit Introduction
This unit is designed to provide learners with essential knowledge and skills related to web
documents that require server-side dynamic interaction. It introduces the core concepts,
technologies, and requirements used to develop modern dynamic websites.
Content Coverage
This unit covers the following topics:
Dynamic Functionality of a Website
Web Scripting Languages
Web Document Requirements
This unit also supports learners in achieving the learning outcomes stated on the course cover
page.
Learning Outcomes
By the end of this unit, learners will be able to:
Determine the dynamic functionality of a website
Explore and evaluate web scripting languages
Understand web document requirements
1.1 Dynamic Functionality of a Website
Dynamic functionality refers to a website’s ability to change content automatically based on
user interaction, time, data, or system events. Website managers must clearly define the type of
dynamic functionality their website provides and manage it accordingly.
Many websites attempt to serve multiple purposes without a clear focus, which can confuse users
and reduce usability.
By defining a website within a specific category, managers can:
Improve user experience
Enhance search engine visibility
Encourage relevant backlinks from related websites
Large corporations and small organizations alike often fail to provide effective dynamic
functionality.
This results in poorly organized portals, outdated content, inefficient customer support systems,
and confusing marketing information.
To determine whether a website is dynamic, a simple question should be asked:
Does the website automatically and frequently change its content or behavior?
Dynamic functionality goes beyond simple design changes such as rotating banners. Examples
include:
Automatically displaying user-generated content
Showing real-time news updates
Updating products and services dynamically
Providing personalized user experiences
In some websites, the dynamic service itself is the primary purpose rather than a secondary
feature.
Categories of Dynamic Functionality Websites
Dynamic websites can be classified into the following categories:
Activity – Enables users to find or create events based on shared interests
Affiliate – Promotes third-party products or services for commission
Archive – Stores and provides searchable access to valuable or legally required data
Blog – Publishes personal or professional online journals
Comedy – Allows users to share or find humorous content
Community – Supports discussions, forums, and shared interests
Company – Provides corporate information for customers and investors
Dating – Facilitates relationship-building between users
Gambling – Allows users to place bets based on odds and outcomes
Investing – Provides research and tools for financial investments
News – Delivers current and updated news content
Personal – Shares personal blogs, photos, or family updates
Political – Influences opinions about political ideas or individuals
Products – Sells goods through online shopping systems
Religious – Offers spiritual guidance and community support
Search – Aggregates and presents information based on user queries
Social – Enables communication and networking among users
1.2 Web Scripting Languages
Web scripting languages are essential tools for developing dynamic websites and online
applications. They enable interaction, automation, and communication between different
systems.
Common web scripting languages include:
PHP
Python
JavaScript
jQuery
Although all scripting languages are programming languages, not all programming languages
are scripting languages. Scripting languages are typically interpreted rather than compiled and
execute within a runtime environment such as a web browser or server.
Characteristics of Scripting Languages
Executed by interpreters instead of compilers
Short and fast to write
Cross-platform compatibility
Commonly open-source
Require minimal system resources
They are ideal for web development because users only need a web browser to execute scripts.
1.2.1 Types of Scripting Languages
There are two main types of web scripting languages:
I. Server-Side Scripting Languages
Server-side scripting languages run on a web server and are not visible to users. This makes them
more secure and suitable for backend operations.
They are commonly used to:
Handle user requests
Process data
Generate dynamic content
Examples:
PHP
Python
[Link]
Perl
Ruby
II. Client-Side Scripting Languages
Client-side scripting languages run in the user’s web browser and are visible to users. They are
mainly used for:
User interface design
Input validation
Interactive features
Since they run locally, they improve performance and reduce server load.
Examples:
HTML
CSS
JavaScript
jQuery
1.2.2 Examples of Scripting Languages
I. JavaScript
JavaScript is one of the most widely used scripting languages on the web. Approximately 98% of
websites use JavaScript.
Key features include:
Dynamic typing
First-class functions
Prototype-based object orientation
II. Python
Python is popular for its simplicity and readability. Developers can write efficient code with
minimal effort.
Key features:
Open-source
Object-oriented and functional programming support
Easy to learn
III. PHP
PHP is a backend scripting language widely used in web development.
Key features:
Easily embedded in HTML
Supports object-oriented programming
Flexible variable handling
IV. Ruby
Ruby is known for its flexibility and clean syntax.
Key features:
Fully object-oriented
Beginner-friendly
Supports rapid application development
V. Perl
Perl is a long-standing scripting language originally developed for text processing.
Key features:
Strong text manipulation capabilities
Widely used in legacy systems
Suitable for scripting and automation
1.2.3 Advantages of Using Scripting Languages
Easy to learn and use
Open-source and free
Portable and cross-platform
Low memory requirements
These advantages make scripting languages ideal for rapid development and dynamic web
applications.
1.2.4 Disadvantages of Using Scripting Languages
Lack of optimization
Slower execution compared to compiled languages
Requires good organization for maintainability
Frequent updates needed for compatibility
1.3 Web Document Requirements
A website requirements document is a critical foundation for any web development project. It
clearly defines the expectations, goals, and features of a website, ensuring effective
communication between stakeholders and developers.
Key Elements of a Website Requirements Document
I. Define the website’s purpose and goals
II. Identify the target audience
III. Determine technical requirements
IV. Specify content requirements
V. Include wireframes and site maps
I. Define Website Purpose and Goals
Common business website goals include:
Educating customers about products and services
Encouraging customer contact
Building brand credibility
Increasing sales and revenue
II. Define Target Audience
Understanding the target audience helps determine:
Design choices
Content tone
Functionality requirements
III. Determine Technical Requirements and Specifications
Important technical considerations include:
Functionality
Accessibility
Integrations
Search features
Analytics
Website styles
IV. Define Content Requirements
Content planning should include:
1. Required web pages
2. Written content per page
3. Visual content
4. Interactive elements
Unit Two: Server-Side Scripts
Unit Overview
Unit Two focuses on server-side scripting, a critical component of modern web development.
Server-side scripts run on a web server and are responsible for processing user requests,
managing data, interacting with databases, and enforcing security controls. Unlike static
websites, server-side scripting enables dynamic web applications where content changes based
on user actions, stored data, and system logic.
This unit emphasizes PHP as the primary server-side scripting language and explains how it
integrates with web servers, databases, and client-side technologies to create complete web
systems.
Learning Outcomes of the Unit
By completing this unit, learners gain both theoretical understanding and practical skills
required to:
Configure and use a local server-side development environment
Write and understand PHP server-side scripts
Control program flow using conditions and loops
Collect, validate, and process user input through web forms
Connect PHP applications to databases and perform data operations
Apply essential security mechanisms to protect web applications
2.1 Development Environment
A development environment is the technical setup that allows developers to write, test, and
debug server-side applications before deployment. Server-side scripts cannot run directly in a
browser; they require a web server and interpreter.
Role of XAMPP
XAMPP is a widely used development environment because it integrates all required
components into a single package:
Apache Web Server – Receives HTTP requests and executes PHP scripts
PHP Interpreter – Processes server-side code
MySQL Database Server – Stores and manages structured data
phpMyAdmin – Provides a graphical interface for database management
Using XAMPP allows developers to simulate a real hosting environment locally, reducing errors
and improving development efficiency.
Apache Web Server
Apache acts as the bridge between the browser and PHP scripts. When a client requests a
PHP page:
1. Apache receives the request
2. Apache sends PHP code to the PHP interpreter
3. PHP executes the script
4. The result (HTML output) is returned to the browser
Without Apache (or a similar server), PHP code cannot function.
MySQL Database Server
MySQL is a relational database management system (RDBMS) that stores data in tables with
rows and columns. It supports:
Data storage and retrieval
Data integrity using keys and constraints
Structured querying using SQL
MySQL is essential for applications that require persistent data such as login systems, records,
transactions, and reports.
2.2 Basic Syntax of Server-Side Scripts
PHP is a server-side scripting language embedded in HTML. It is executed on the server, and
only the output (HTML) is sent to the client.
Key Characteristics of PHP
Server-side execution
Loosely typed language
Platform independent
Supports procedural and object-oriented programming
Integrates easily with databases
PHP scripts are enclosed within <?php ... ?> tags and saved with a .php extension.
PHP Variables
Variables are used to store data temporarily during script execution.
Declared using the $ symbol
Case-sensitive
Do not require explicit data type declaration
Variables allow dynamic behavior such as calculations, condition checks, and data manipulation.
PHP Data Types
PHP supports multiple data types to handle different kinds of information:
Scalar types: integer, float, string, boolean
Compound types: arrays (store multiple values), objects
Special types: NULL (empty variable), resource (external references)
Understanding data types is essential for proper data handling and validation.
PHP Operators
Operators allow PHP scripts to perform operations and make decisions. Major operator
categories include:
Arithmetic operators for calculations
Logical operators for conditions
Comparison operators for evaluating expressions
Assignment operators for storing values
String operators for text processing
Array operators for handling collections
Increment/decrement operators for loop control
Operators form the backbone of application logic.
PHP Comments
Comments improve code readability and maintainability.
Single-line comments explain individual statements
Multi-line comments document larger code blocks
They are ignored during execution and used mainly for documentation.
2.3 Control Structures in PHP
Control structures define how a program flows and responds to conditions.
Conditional Statements
Conditional statements enable decision-making:
if – Executes code when a condition is true
if–else – Provides alternative execution paths
if–elseif–else – Handles multiple conditions
switch – Selects execution based on specific values
These structures are critical for validation, logic branching, and user interaction.
Loop Statements
Loops allow repeated execution of code blocks:
while loop – Used when repetitions are unknown
do–while loop – Executes at least once
for loop – Used when repetition count is known
Loops are essential for processing lists, database records, and repetitive tasks.
Jump Statements
Jump statements modify loop behavior:
break – Terminates loop execution
continue – Skips the current iteration
They enhance control and efficiency in program execution.
2.4 Forms and User Input
Forms are the primary method of user interaction in web applications. PHP processes form data
on the server after submission.
Form Components
<form> element defines the form
action specifies the processing script
method defines data transmission method
Input fields collect user data such as text, passwords, files, and selections.
GET and POST Methods
GET
o Data visible in URL
o Limited size
o Less secure
o Used for search and navigation
POST
o Data hidden from URL
o More secure
o Supports large data
o Used for login, registration, uploads
PHP uses $_GET and $_POST super global arrays to retrieve submitted data.
2.5 Working with Databases
Databases provide persistent data storage for web applications. PHP interacts with databases
to:
Insert data
Retrieve data
Update records
Delete records
PHP–MySQL Connection Methods
MySQL – Deprecated due to security issues
MySQLi – Improved performance and security
PDO – Database abstraction and portability
PDO is preferred for large and scalable applications.
phpMyAdmin
phpMyAdmin is a web-based database management tool that:
Manages databases and tables
Executes SQL queries
Controls users and permissions
Imports and exports data
It simplifies database administration without requiring command-line operations.
2.6 Security Features in Web Development
Security protects applications from unauthorized access, data loss, and attacks.
Core Web Security Concepts
Domain security (registry lock)
Resource protection (hotlink prevention)
Traffic control (DDoS protection)
Data encryption (SSL/TLS)
Authentication (two-factor verification)
Access control (strong passwords)
Attack prevention (bot blocking, XSS protection)
Disaster recovery (data backups)