Modern Web Applications
Modern Web Applications
The Internet began in 1969 as a project of the U.S. Department of Defense called ARPANET, or
Advanced Research Projects Agency Network. The goal of this project was to design a
nationwide computer network that could withstand major disasters. If one part of the network
was destroyed, the other parts would continue to function due to the decentralized structure of
the network.
In the early days of ARPANET, there were four computers in the United States attached to the
network. Today, there are millions all over the world. Most people define the Internet as a
collection of computer networks, but what exactly is a network? A network is a group of two or
more computers connected together with cables that allow the computers to share information.
Computers that are “on the Internet” all use the same protocols to send information back and
forth, allowing them to communicate with each other. As long as a computer uses these
protocols, it doesn't matter what type of hardware or software it uses.
In the Internet's early days (the 1960s and 1970s), only government, military, and educational
institutions had computers connected to the Internet. The Internet was originally designed for
research and scholarly communication. But as it grew, its services became more popular, and
new ways of using the Internet multiplied. For example, the Internet began to be used for
informal communication, entertainment, and eventually commerce, as more businesses
connected to the Internet in the 1990s. According to statistics compiled by Nua Internet Surveys
Ltd., some 605.60 million people worldwide were connected to the Internet as of September
2002.
Today, the Internet remains decentralized, but it is no longer structured entirely around
government computers. It is comprised of independently owned and managed individual
networks of all sizes. The larger networks with high-speed connections are sometimes called
backbone providers.
Internet Service Providers (ISPs) lease Internet connections from the backbone providers and
sell connections (also called Internet accounts) to consumers. Most home and small business
users connect to the Internet with dial-up accounts to ISPs using a modem and special
communications software.
Uses for the Internet The Internet is significant for libraries, providing free access to various
services:
● Email: For sending messages.
● Telnet: For remote computer access.
● File Transfer Protocol (FTP): For transferring files.
● Usenet: For group discussions.
● Internet Relay Chat (IRC): For real-time chatting.
● World Wide Web (WWW): For accessing countless websites.
What is the World Wide Web?
One reason for the Internet's growth explosion is the ease of use and popularity of the World
Wide Web and its graphical, “point-and-click” user interface. The World Wide Web was invented
in 1989 by Tim Berners-Lee, a scientist at the European Particle Physics Laboratory (CERN) in
Geneva, Switzerland. Lee wanted to make the information he used for research on the Internet
more organized and accessible.
The World Wide Web is based on hypertext, which is a method of linking documents using
embedded hyperlinks. Hyperlinks can be text, which is usually underlined or a different color
than the main text, or graphics. World Wide Web documents are created using a special
computer language called HTML (Hypertext Markup Language). HTML coding embeds clickable
links in documents and enables simple formatting.
Documents written in HTML are stored in computers called servers. Any Internet user who has
A web browser can retrieve the documents. A Web browser is a computer program that knows
how to read and display hypertext documents. It also knows how to communicate with servers
that store HTML files. The protocol used for this kind of communication is called Hypertext
Transfer Protocol (HTTP). Documents on the World Wide Web are called Web pages. Web
pages are organized into Web sites. Each Web page has its own address, known formally as a
Uniform Resource Locator or URL.
➔ http://www.cnn.com/WEATHER/cities/asiapcf.html.
When you enter a URL in a Web browser, or if you click a hypertext link, the browser sends a
message using the HTTP protocol to the computer identified in the URL. This message contains
a request for the document specified in the URL. The server sends a copy of the document back
to the browser, and it is displayed on your screen.
Understanding a few things about URLs and other Internet addresses can make using the Web
a lot easier. The domain name (the name of the computer) in a URL can be assigned by a large
number of businesses. Just type "domain name" into your search engine, and you will find
companies who can register your top-level domain name. The Internet Corporation for Assigned
Names and Numbers (ICANN) Web site at www.icann.org has a long list of accredited domain
name registrars. There are standard suffixes for domain names, called extensions, which help
identify what type of organization owns the domain. For example, domain names ending in .com
indicate a commercial organization.
Web Browser and protocol
When we need any kind of information most of the time we get help from the Internet, and we
get information. The Internet provides us with useful information easily. We use mobile phones,
computers, and tablets. We search for a lot of things in our daily lives, so we get information
about all over the world, but we can not get information by just only getting connected to the
Internet. We need a platform where we can search for our questions. The platform that provides
such kinds of services is called a web browser, without a web browser internet will not be able to
provide information.
The web browser is an application software to explore www (World Wide Web). It provides an
interface between the server and the client and it requests to the server for web documents and
services. It works as a compiler to render HTML which is used to design a webpage. Whenever
we search for anything on the internet, the browser loads a web page written in HTML, including
text, links, images, and other items such as style sheets and JavaScript functions. Google
Chrome, Microsoft Edge, Mozilla Firefox, and Safari are examples of web browsers.
A web browser helps us find information anywhere on the internet. It is installed on the client
computer and requests information from the web server such a type of working model is called a
client-server model.
The browser receives information through HTTP protocol. In which transmission of data is
defined. When the browser receives data from the server, it is rendered in HTML to
user-readable form, and, information is displayed on the device screen.
A protocol is a set of rules or standards that define how data is transmitted and received over a
network. These rules ensure that different devices and systems can communicate with each
other effectively, regardless of their underlying hardware or software.
It may also use the Transport Layer Security (TLS) protocol to serve the website over a secure,
encrypted connection.
The web browser uses these protocols on top of the Internet protocols, so every HTTP request
also uses TCP and IP.
Transmission Control Protocol (TCP): Ensures reliable, ordered, and error-checked delivery
of data between applications.
Internet Protocol (IP): Handles addressing and routing of packets of data so they can travel
across networks and arrive at the correct destination.
The Web is just one of the applications built on top of the Internet protocols, but it is by far the
most popular.
Web application
The Internet is no longer about static web pages and longer loading times. Over time, the
Internet has made a shift towards active user engagement as well as extended functionality by
means of visually pleasing and powerful web applications.
A web application, or web app, is a software program that runs on a web server and is accessed
through a web browser over the Internet. Unlike traditional desktop applications, web
applications do not need to be installed on a user's device. Users interact with web applications
through a web browser interface. A web application is just like a normal computer application
except that it works over the Internet. As everyone is on the web these days, most developers
are looking to benefit from web apps and attract as many users as possible via opportune
offerings.
● Client Component - The client component is developed in CSS, HTML, and JS. As it
exists within the user’s web browser, there is no need for operating system or
device-related adjustments. The client component is a representation of a web
application’s functionality that the end-user interacts with.
● Server Component - The server component can be built using one or a combination of
several programming languages and frameworks, including Java, .Net, NodeJS, PHP,
Python, and Ruby on Rails. The server component has at least two parts; app logic and
database. The former is the main control center of the web application while the latter is
where all the persistent data is stored.
URL
URL is the abbreviation of Uniform Resource Locator. It is the resource address on the internet.
The URL (Uniform Resource Locator) was created by Tim Berners-Lee and the Internet
Engineering working group in 1994. URL is the character string (address) that is used to access
data from the internet. The URL is the type of URI (Uniform Resource Identifier).
Components of a URL.
1. Protocol: Indicates the method used to access the resource. Common protocols
include:
○ http:// (Hypertext Transfer Protocol)
○ https:// (Hypertext Transfer Protocol Secure)
○ ftp:// (File Transfer Protocol)
2. Domain Name: Identifies the server hosting the resource. For example, in
https://www.example.com, example.com is the domain name.
3. Port Number: Optional part that specifies the port to be used for the connection. For
example, :80 is often implied for HTTP, and :443 for HTTPS.
4. Path: Specifies the exact resource or directory on the server. For example,
/about/index.html.
5. Query String: Optional part that provides additional parameters. It follows a ? and
includes key-value pairs separated by &. For example, ?id=123&name=John.
6. Fragment Identifier: Optional part that refers to a specific section within a resource. It
follows a #. For example, #section2.
3 Tiered architecture
The chief benefit of the three-tier architecture is that because each tier runs on its own
infrastructure, each tier can be developed simultaneously by a separate development team. And
can be updated or scaled as needed without impacting the other tiers.
Presentation tier
The presentation tier is the user interface and communication layer of the application, where the
end-user interacts with the application. Its main purpose is to display information to and collect
information from the user. This top-level tier can run on a web browser, as the desktop
application, or a graphical user interface (GUI), for example. Web presentation tiers are
developed by using HTML, CSS, and JavaScript. Desktop applications can be written in various
languages depending on the platform.
Application tier
The application tier, also known as the logic tier or middle tier, is the heart of the application. In
this tier, information that is collected in the presentation tier is processed - sometimes against
other information in the data tier - using business logic, a specific set of business rules. The
application tier can also add, delete, or modify data in the data tier.
The application tier is typically developed by using Python, Java, Perl, PHP, or Ruby, and
communicates with the data tier by using API calls.
Data tier
The data tier, sometimes called database tier, data access tier, or back-end, is where the
information that is processed by the application is stored and managed. This can be a relational
database management system such as PostgreSQL, MySQL, MariaDB, Oracle, Db2, Informix,
or Microsoft SQL Server, or a NoSQL Database server such as Cassandra, CouchDB, or
MongoDB.
In a three-tier application, all communication goes through the application tier. The presentation
tier and the data tier cannot communicate directly with one another.
N-tier architecture
N-tier architecture - also called multitier architecture - refers to any application architecture with
more than one tier. But applications with more than three layers are rare because extra layers
offer few benefits and can make the application slower, harder to manage, and more expensive
to run. As a result, n-tier architecture and multitier architecture are usually synonyms for
three-tier architecture.
HTML
HTML, or HyperText Markup Language, is the standard markup language used to create web
pages. It’s a combination of Hypertext, which defines the link between web pages, and Markup
language, which is used to define the text document within tags to structure web pages. This
language is used to annotate text so that machines can understand and manipulate it
accordingly. HTML is human-readable and uses tags to define what manipulation has to be
done on the text.
HTML tags are composed of an opening tag, content, and a closing tag. The opening tag marks
the beginning of an element, and the closing tag marks the end. The content is the information
or structure that falls between the opening and closing tags. Here’s the basic structure of an
HTML tag:
<tagname> Content... </tagname>
Tag Name Description Example
HTML Lists
An HTML list is a record of related information used to display the data or any information on
web pages in the ordered or unordered form.
The unordered list items are marked with bullets. It is also known as bulleted lists. An unordered
list starts with the <ul> tag. Each list item starts with the <li> tag.
Syntax:
<ul> list of items </ul>
Attribute: This tag contains two attributes which are listed below:
➔ compact: The HTML <ul> compact Attribute is used to define the list should be smaller
than normal by reducing the space between the list items and the indentation of the list.
It is a Boolean attribute.<ul compact>
➔ type: The HTML <ul> type attribute in the <ul> tag specifies the type of marker used in
an unordered list. Values include disc (default filled circle), circle (hollow circle), square,
and none. It controls the appearance of list items.<ul type="disc | circle |
square">
Attribute Values:(Bullets ke design)
● disc: Default. A filled circle.
● circle: An unfilled circle
● square A filled square.
Example
A description list is a list of terms, with a description of each term. The <dl> tag defines the
description list, the <dt> tag defines the term name, and the <dd> tag describes each term.
Syntax:
<dl> Contents... </dl>
Example-
External CSS
With an external style sheet, you can change the look of an entire website by changing just one
file!
Each HTML page must include a reference to the external style sheet file inside the <link>
element, inside the head section.
An external style sheet can be written in any text editor and must be saved with a .css
extension.
The external .css file should not contain any HTML tags.
Internal CSS
An internal style sheet may be used if one single HTML page has a unique style.
The internal style is defined inside the <style> element, inside the head section.
Inline CSS
An inline style may be used to apply a unique style to a single element.
To use inline styles, add the style attribute to the relevant element. The style attribute can
contain any CSS property.
Cascading Style Sheets (CSS) is a language used to style web pages that contain HTML
elements, defining how elements are displayed on webpages, including layout, colors, fonts,
and other properties of the elements on a web page. CSS works by targeting HTML elements
and applying style rules to define how they should be displayed, including properties like color,
size, layout, and positioning.
CSS selectors
CSS selectors are the backbone of any stylish webpage. They target HTML elements on your
pages, allowing you to add styles based on their id, class, type, attribute, and more.
1. Universal Selector (*)
Example:
css
* {
margin: 0;
padding: 0;
2. Type Selector
Example:
css
p {
color: blue;
3. Class Selector
Example:
css
.highlight {
background-color: yellow;
}
html
4. ID Selector
Example:
css
#header {
font-size: 24px;
color: green;
html
<div id="header">This is the header</div>
5. Attribute Selector
Example:
css
a[target="_blank"] {
color: red;
html
<a href="https://example.com" target="_blank">External Link</a>
6. Descendant Selector
div p {
color: brown;
html
<div>
</div>
7. Child Selector
Example:
css
ul > li {
list-style-type: none;
html
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
8 . Pseudo-Class Selector
● Description: Selects elements based on their state.
Example:
css
a:hover {
color: orange;
html
<a href="https://example.com">Hover over this link</a>
9 . Pseudo-Element Selector
Example:
css
p::first-line {
font-weight: bold;
html
<p>This is a paragraph with the first line in bold.</p>
The <form> element is a container for different types of input elements, such as: text fields,
checkboxes, radio buttons, submit buttons, etc.
The <input> Element
The HTML <input> element is the most used form element.
An <input> element can be displayed in many ways, depending on the type attribute.
Text Fields
The <input type="text"> defines a single-line input field for text input.
Radio Buttons
The <input type="radio"> defines a radio button.
Radio buttons let a user select ONE of a limited number of choices.
Checkboxes
<h2>User Registration</h2>
<label for="email">Email:</label><br>
<input type="email" id="email" name="email" required><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password" required><br>
</body>
</html>
Bootstrap
Bootstrap is a free and open-source tool collection for creating responsive websites and web
applications. It is the most popular HTML, CSS, and JavaScript framework for developing
responsive, mobile-first websites. Nowadays, the websites are perfect for all browsers (IE,
Firefox, and Chrome) and for all sizes of screens (Desktop, Tablets, Phablets, and Phones). All
thanks to Bootstrap developers – Mark Otto and Jacob Thornton of Twitter, though it was later
declared to be an open-source project.
By using this framework we can easily manipulate the styling of any web page, like font style,
text color, background color, flex, grid system, etc. Bootstrap Vesrion 4 & Vesrion 5 are the most
popular versions. There are lots of other CSS frameworks like Tailwind CSS, Bulma, and
Foundation but among them, this framework is the most popular because of below mentioned
features:
Features of bootstrap
1. Responsive Design: Bootstrap makes it easy to create responsive layouts that adapt to
different screen sizes, ensuring your website looks great on all devices.
2. CSS Grid System: Bootstrap's grid system allows you to create complex layouts with
rows and columns, making it simple to organize content on your webpage.
3. Pre-styled Components: Bootstrap comes with a wide range of pre-styled components
such as buttons, forms, navigation bars, and more, which you can easily customize to fit
your design.
4. Extensive Documentation: Bootstrap has comprehensive documentation with examples
and guidelines for using its components and features effectively.
5. Browser Compatibility: Bootstrap ensures cross-browser compatibility, so your website
will work consistently across different web browsers.
6. Customizable: While Bootstrap provides ready-to-use components, it's also highly
customizable, allowing you to override default styles and create a unique look for your
website.
Bootstrap's grid system is based on a 12-column layout, which makes it easy to create
responsive and flexible designs. Here are some key concepts of the Bootstrap grid system:
● Containers: Containers are the outermost elements that hold the grid system. They
provide a consistent padding and are used to center and contain the layout.
● Rows: Rows are horizontal containers for columns. They ensure proper alignment and
padding of columns.
● Columns: Columns are the building blocks of the grid system. They are placed inside
rows and can span a specified number of columns across different screen sizes (e.g., xs,
sm, md, lg, xl).
Bootstrap provides various classes for styling form elements. Some commonly used classes for
a Bootstrap form include:
● form-control: Applies styles to form elements like input, select, textarea to make them
look consistent.
● form-group: Groups form elements together and adds margin between them.
● form-check: Styles checkboxes and radio buttons.
● form-check-label: Styles the label for checkboxes and radio buttons.
● btn: Styles buttons.
● btn-primary, btn-secondary, etc.: Styles buttons with different colors.
To create buttons using Bootstrap, you can use the <button> element or the <a> element with
appropriate Bootstrap classes. Here's an example:
In this example, we've created two buttons: one using the <button> element and the other
using the <a> element. Both buttons use Bootstrap classes (btn and btn-primary or
btn-secondary) to apply styling.
CSS positioning
CSS positioning is a crucial aspect of web design that allows you to precisely control the layout
and placement of elements on a webpage. There are several CSS positioning properties that
you can use to position elements:
Static Positioning: This is the default positioning behavior, where elements are positioned
according to the normal flow of the document. You typically don't need to explicitly set the
position property for static positioning.
css
.element {
/* Default positioning */
}
Relative Positioning: Relative positioning allows you to position elements relative to their
normal position in the document flow. You can use the top, right, bottom, and left
properties to adjust the element's position relative to where it would normally be.
.element {
position: relative;
top: 20px;
left: 10px;
Absolute Positioning: Absolute positioning removes the element from the normal document
flow and positions it relative to its nearest positioned ancestor (an ancestor element with a
position other than static) or the initial containing block (typically the viewport if no positioned
ancestor is found).
.element {
position: absolute;
top: 50px;
left: 50px;
Fixed Positioning: Fixed positioning positions the element relative to the viewport, so it
remains fixed in the same position even when the page is scrolled.
.element {
position: fixed;
top: 0;
right: 0;
Sticky Positioning: Sticky positioning is a hybrid of relative and fixed positioning. It acts like
relative positioning until the element reaches a specified threshold (usually based on the scroll
position), after which it becomes fixed.
.element {
position: sticky;
top: 0;
Understanding these CSS positioning properties and when to use them is essential for creating
complex layouts and achieving the desired visual appearance of your webpage.
XML
Extensible Markup Language (XML) is a type of markup language that establishes a set of
guidelines for encoding texts in a way that is both machine- and human-readable. For storing
and transferring data on the web and in many other applications, XML is widely used. XML
steps in as a versatile tool for encoding and organizing data in a way that both humans and
machines can comprehend.
XML emerged in the late 1990s as a revolutionary concept in the evolving landscape of the
internet. Before XML, HTML served as the predominant language for web content, but it lacked
the flexibility needed for complex data representation. XML arrived as a solution, offering a
standardized format for expressing diverse types of data in a hierarchical structure.
In the realm of XML, everything revolves around tags. Think of tags as containers that hold
different pieces of information. Each tag has a name and can optionally carry attributes,
providing additional details about the enclosed data.
XML attributes provide additional information about XML elements. They are always included
within the start tag of an element and consist of a name/value pair. Attributes are often used to
convey metadata about the element or to specify properties that affect the element's content or
behavior.
Key Points about XML Attributes
<title>XML Tutorial</title>
<author>John Doe</author>
<price>29.99</price>
</book>
In this example:
XML Schema
XML Schema is a way to define the structure, content, and semantics of XML documents. It is
used to validate XML documents to ensure they adhere to a defined structure and set of rules.
● Data Types: XML Schema defines various data types (e.g., string, integer, date) that can
be used to validate the content of XML elements and attributes.
● Element and Attribute Declarations: It specifies the elements and attributes that can
appear in an XML document and their relationships.
● Namespace Support: XML Schema supports namespaces, which allow you to avoid
element name conflicts.
● Complex Types: It allows the definition of complex data types that can include elements
and attributes.
● Inheritance: XML Schema supports inheritance, allowing the creation of new complex
types based on existing ones.
Advantages of XML
● Human-readable: XML’s straightforward tag-based syntax makes it easy for humans to
read and understand. This readability promotes collaboration and understanding among
developers and other stakeholders.
● Interoperability: XML facilitates data sharing between different systems, regardless of
the underlying technology. Like a skilled interpreter, XML bridges the communication gap
between disparate systems, enabling seamless data exchange. Whether it’s sharing
data between different applications or integrating systems from different vendors, XML
ensures interoperability and compatibility.
● Flexibility: XML’s adaptability allows it to handle a wide range of data types and
structures, offering a canvas for expressing diverse information. Whether it’s simple text
data, complex hierarchical data, or metadata describing data relationships, XML can
accommodate it all.
● Simplicity: XML is easy to read and write.
● Self-descriptive: XML documents can be self-descriptive, making it easy to understand
the data structure.
Disadvantages of XML
1. Verbose: XML documents can become large and verbose, which can lead to increased
storage and transmission costs.
2. Performance: Parsing XML can be slower compared to other formats like JSON.
3. Complexity: Complex XML schemas can be difficult to manage and understand.
4. Overhead: XML has a significant amount of overhead due to its verbose nature, which
can affect performance.
3. No Spaces:
● Names cannot contain spaces.
4. Case-Sensitive:
● Names are case-sensitive. For example, <name> and <Name> are considered different
elements.
●
5. Avoid XML Reserved Words:
● Names should not match XML reserved words like xml in any combination of cases
(xml, Xml, XML, etc.).
Creating Elements
Elements in a DTD are defined using the <!ELEMENT> declaration. You specify the name of the
element and its content model (what elements can appear within it).
Syntax:
xml
Example:
xml
In this example, the book element contains three child elements: title, author, and year.
Creating Attributes
Attributes in a DTD are defined using the <!ATTLIST> declaration. You specify the name of the
element, the name of the attribute, its data type, and any default or fixed values.
Syntax:
xml
xml
In this example, the book element has an attribute named genre with a data type of CDATA
(character data). The #IMPLIED keyword indicates that the attribute is optional.
JavaScript Array
JavaScript object is a variable that can store multiple data in key-value pairs.
The syntax of JavaScript object is:
const objectName = {
key1: value1,
key2: value2,
...,
keyN: valueN
};
Here,
● objectName - Name of the object.
● key1: value1 - The first key-value pair.
● key2: value2 - The second key-value pair.
● keyN: valueN - The Nth key-value pair.
Each key-value pair has a colon : between them and is separated by a comma ,.
In JavaScript, the key-value pairs of an object are referred to as properties.
Here, we've only listed a few fruits. But what if we need to store 100 fruits?
For such a case, the easiest solution is to store them in an array.
let fruits = ["Apple", "Banana", "Orange", ...];
An array can store many values in a single variable, making it easy to access them by referring
to the corresponding index number.
Create an Array
We can create an array by placing elements inside an array literal [], separated by commas. For
example,
const numbers = [10, 30, 40, 60, 80];
Here,
● numbers - Name of the array.
● [10, 30, 40, 60, 80] - Elements of the array.
// array of strings
const dailyActivities = ["eat", "work", "sleep"];
Note: Unlike many other programming languages, JavaScript allows us to create arrays with
mixed data types.
Access Elements of an Array
Each element of an array is associated with a number called an index, which specifies its
position inside the array.
Consider the following array:
let numbers = [10, 30, 40, 60, 80];
Here is the indexing of each element:
Code Description
console.log(dailyActivities);
console.log(dailyActivities);
console.log(dailyActivities);
console.log(numbers);
// Output: [ 1, 2, 4, 5 ]
In this example, we removed the element at index 2 (the third element) using the splice()
method.
Array Methods
JavaScript has various array methods to perform useful operations. Some commonly used array
methods in JavaScript are:
Method Description
findIndex() Returns the first index of the array element that passes a given test.
DOM
DOM, or Document Object Model, is a programming interface that represents structured
documents like HTML and XML as a tree of objects. It defines how to access, manipulate, and
modify document elements using scripting languages like JavaScript.
So basically Document Object Model is an API that represents and interacts with HTML or XML
documents.
The DOM is a W3C (World Wide Web Consortium) standard and it defines a standard for
accessing documents.
The W3C Dom standard is divided into three different parts:
● Core DOM – standard model for all document types
● XML DOM – standard model for XML documents
● HTML DOM – standard model for HTML documents
HTML DOM
HTML DOM is a standard object model and programming interface for HTML documents. HTML
DOM is a way to represent the webpage in a structured hierarchical way so that it will become
easier for programmers and users to glide through the document.
With HTML DOM, we can easily access and manipulate tags, IDs, classes, attributes, or
elements of HTML using commands or methods provided by the document object.
Using DOM JavaScript we get access to HTML as well as CSS of the web page and can also
modify the behavior of the HTML elements.
Structure of DOM
DOM can be thought of as a Tree or Forest (more than one tree). The term structure model is
sometimes used to describe the tree-like representation of a document.
Each branch of the tree ends in a node, and each node contains objects Event listeners can be
added to nodes and triggered on an occurrence of a given event. One important property of
DOM structure models is structural isomorphism: if any two DOM implementations are used to
create a representation of the same document, they will create the same structure model, with
precisely the same objects and relationships.
Why DOM is called an Object Model?
Documents are modeled using objects, and the model includes not only the structure of a
document but also the behavior of a document and the objects of which it is composed like tag
elements with attributes in HTML.
● Window Object: Window Object is object of the browser which is always at top of the
hierarchy. It is like an API that is used to set and access all the properties and methods
of the browser. It is automatically created by the browser.
● Document object: When an HTML document is loaded into a window, it becomes a
document object. The ‘document’ object has various properties that refer to other objects
which allow access to and modification of the content of the web page. If there is a need
to access any element in an HTML page, we always start with accessing the ‘document’
object. Document object is property of window object.
● Form Object: It is represented by form tags.
● Link Object: It is represented by link tags.
● Anchor Object: It is represented by a href tags.
● Form Control Elements: Form can have many control elements such as text fields,
buttons, radio buttons, checkboxes, etc.
In JavaScript, the window object and the document object are two fundamental objects that are
part of the browser's Document Object Model (DOM). They provide access to the browser's
functionality and the content of the web page, respectively.
1. Properties:
○ window.innerWidth and window.innerHeight: Width and height of the
window's content area.
○ window.location: Contains information about the current URL.
○ window.document: References the document object loaded in that window.
2. Methods:
○ window.alert(message): Displays an alert box with a specified message.
○ window.confirm(message): Displays a dialog box with a specified message
and "OK" and "Cancel" buttons.
○ window.prompt(message, default): Displays a dialog box that prompts
the user for input.
○ window.open(url, name, specs): Opens a new browser window or tab.
○ window.setTimeout(function, milliseconds): Calls a function after a
specified number of milliseconds.
○ window.setInterval(function, milliseconds): Calls a function
repeatedly at specified intervals.
The document Object
The document object represents the HTML or XML document loaded in the window. It is a
property of the window object and provides methods and properties to interact with the DOM
(Document Object Model).
1. Properties:
○ document.body: Represents the <body> element.
○ document.head: Represents the <head> element.
○ document.title: Gets or sets the title of the document.
○ document.URL: Returns the URL of the document.
○ document.forms: Returns a collection of all <form> elements.
2. Methods:
○ document.getElementById(id): Returns the element with the specified ID.
○ document.getElementsByClassName(className): Returns a collection of
all elements with the specified class name.
○ document.getElementsByTagName(tagName): Returns a collection of all
elements with the specified tag name.
○ document.querySelector(selector): Returns the first element that
matches a specified CSS selector.
○ document.querySelectorAll(selector): Returns all elements that match
a specified CSS selector.
○ document.createElement(tagName): Creates a new element with the
specified tag name.
Event handling is the mechanism that allows you to capture and respond to user actions like
clicks, key presses, or mouse movements. JavaScript provides several ways to handle events.
1. Inline Event Handling You can directly add event handlers in HTML elements using
attributes like onclick.
Example:
Html
Example:
html
<!DOCTYPE html>
<html>
<head>
<title>Event Handling Example</title>
</head>
<body>
<button id="myButton">Click Me</button>
<script>
document.getElementById('myButton').addEventListener('click',
function() {
alert('Button clicked!');
});
</script>
</body>
</html>
JS radiobutton and checkbox
<html>
<head>
<title>Simple Form Example</title>
</head>
<body>
<form id="myForm">
<p>Choose your favorite color:</p>
<label>
<input type="radio" name="color" value="Red"> Red
</label>
<label>
<input type="radio" name="color" value="Green"> Green
</label>
<label>
<input type="radio" name="color" value="Blue"> Blue
</label>
<br>
<script>
function submitForm() {
// Get selected color
const colors = document.getElementsByName('color');
let selectedColor = '';
for (const color of colors) {
if (color.checked) {
selectedColor = color.value;
break;
}
}
In JavaScript, the alert(), confirm(), and prompt() functions are used to display dialog
boxes to the user. These dialog boxes are part of the built-in functions provided by the browser
and can be used to display information, ask for confirmation, or gather input from the user.
1. Alert Box
The alert() function displays a simple message to the user. The user can only click "OK" to
close the alert box.
Syntax:
javascript
alert("This is an alert box!");
Example:
html
<!DOCTYPE html>
<html>
<head>
<title>Alert Example</title>
</head>
<body>
<button onclick="showAlert()">Show Alert</button>
<script>
function showAlert() {
alert("This is an alert box!");
}
</script>
</body>
</html>
2. Confirm Box
The confirm() function displays a message to the user with "OK" and "Cancel" buttons. It
returns true if the user clicks "OK" and false if the user clicks "Cancel".
Syntax:
javascript
let userConfirmed = confirm("Do you confirm this action?");
Example:
html
<!DOCTYPE html>
<html>
<head>
<title>Confirm Example</title>
</head>
<body>
<button onclick="showConfirm()">Show Confirm</button>
<script>
function showConfirm() {
let userConfirmed = confirm("Do you confirm this
action?");
if (userConfirmed) {
alert("You clicked OK.");
} else {
alert("You clicked Cancel.");
}
}
</script>
</body>
</html>
3. Prompt Box
The prompt() function displays a message to the user with an input field. The user can type in
a value and click "OK" to submit it or click "Cancel" to close the prompt box without submitting a
value. It returns the input value if the user clicks "OK" or null if the user clicks "Cancel".
Syntax:
javascript
let userInput = prompt("Please enter your name:", "Default Value");
Example:
html
<!DOCTYPE html>
<html>
<head>
<title>Prompt Example</title>
</head>
<body>
<button onclick="showPrompt()">Show Prompt</button>
<script>
function showPrompt() {
let userInput = prompt("Please enter your name:", "Default
Value");
if (userInput !== null) {
alert("Hello, " + userInput + "!");
} else {
alert("You cancelled the prompt.");
}
}
</script>
</body>
</html>
Summary
These dialog boxes are useful for simple interactions and gathering basic input from users:
These are basic built-in functions provided by JavaScript for simple user interactions and can be
used in various scenarios to enhance user experience.
The Math object in JavaScript is a built-in object that has properties and methods for
mathematical constants and functions. Unlike other global objects, the Math object has no
constructor. All its properties and methods are static, meaning you can use them directly without
creating a Math object instance.
Here are explanations and examples of five commonly used methods of the Math object:
1. Math.abs()
The Math.abs() method returns the absolute value of a number, which is the number without
its sign.
Example:
console.log(absoluteValue); // Output: 5
2. Math.round()
The Math.round() method rounds a number to the nearest integer. If the fractional part of the
number is 0.5 or greater, the argument is rounded to the next higher integer. If it is less than 0.5,
the argument is rounded to the next lower integer.
Example:
console.log(roundedNumber); // Output: 5
3. Math.max()
Example:
console.log(maxNumber); // Output: 9
4. Math.min()
Example:
console.log(minNumber); // Output: 2
5. Math.random()
Example:
let randomNumber = Math.random();
Purpose of XSLT
The primary purpose of XSLT is to define how one XML document is transformed into another
XML document or other formats. It allows developers to separate the data from its presentation,
enabling flexible, dynamic, and reusable content transformations.
Advantages of XSLT
1. Separation of Content and Presentation: XSLT allows you to keep the data separate
from its presentation, making it easier to manage and style data dynamically.
2. Reusability: XSLT stylesheets can be reused across multiple XML documents with
similar structures.
3. Flexibility: XSLT can transform XML data into various formats, including HTML, plain
text, and other XML schemas.
Disadvantages of XSLT
1. Complexity: Writing and maintaining XSLT can be complex, especially for large or
highly structured transformations.
2. Performance: XSLT transformations can be resource-intensive, affecting performance
for large XML documents.
3. Learning Curve: XSLT has a steep learning curve for those unfamiliar with XML and
XPath.
Summary
XSLT is a powerful tool for transforming XML documents into different formats. It provides a
flexible and reusable way to manage the presentation of XML data separately from the data
itself. Despite its complexity and potential performance issues, XSLT remains a valuable
technology for XML data transformation.
PHP
The term PHP is an acronym for – Hypertext Preprocessor. PHP is a server-side scripting
language designed specifically for web development. It is open-source which means it is free to
download and use. It is very simple to learn and use. The file extension of PHP is “.php”.
Characteristics of PHP
● PHP code is executed in the server.
● It can be integrated with many databases such as Oracle, Microsoft SQL Server,
MySQL, PostgreSQL, Sybase, and Informix.
● It is powerful to hold a content management system like WordPress and can be used to
control user access.
● It supports main protocols like HTTP Basic, HTTP Digest, IMAP, FTP, and others.
● Websites like www.facebook.com and www.yahoo.com are also built on PHP.
● One of the main reasons behind this is that PHP can be easily embedded in HTML files
and HTML codes can also be written in a PHP file.
● The thing that differentiates PHP from the client-side language like HTML is, that PHP
codes are executed on the server whereas HTML codes are directly rendered on the
browser. PHP codes are first executed on the server and then the result is returned to
the browser.
● The only information that the client or browser knows is the result returned after
executing the PHP script on the server and not the actual PHP codes present in the PHP
file. Also, PHP files can support other client-side scripting languages like CSS and
JavaScript.
Purpose of using PHP
● PHP is primarily used for server-side web development. It enables the creation of
dynamic web pages by embedding PHP code within HTML.
● PHP can perform various tasks, including handling form data, generating dynamic page
content, managing databases, and interacting with servers.
Syntax
<?php
PHP code goes here
?>
Example
<html>
<head>
<title>PHP Hello World</title>
</head>
<body>
<?php echo "Hello, World! This is PHP code";?>
</body>
</html>
Features of PHP
● Dynamic Typing: PHP is dynamically typed, meaning you don’t need to declare the data
type of a variable explicitly.
● Cross-Platform: PHP runs on various platforms, making it compatible with different
operating systems.
● Database Integration: PHP provides built-in support for interacting with databases, such
as MySQL, PostgreSQL, and others.
● Server-Side Scripting: PHP scripts are executed on the server, generating HTML that is
sent to the client’s browser.
Advantages of PHP
1. Open Source: PHP is free to use and distribute, benefiting from a large developer
community that contributes to its continuous growth and improvement.
2. Easy to Learn: PHP's syntax is similar to C and other programming languages, making
it accessible for developers, especially those with prior programming experience.
3. Web Integration: Designed for web development, PHP integrates seamlessly with
HTML and various web technologies, facilitating the creation of dynamic and interactive
web pages.
4. Database Support: PHP offers robust support for multiple databases, including MySQL,
PostgreSQL, and SQLite, making database interactions straightforward and efficient.
5. Cross-Platform Compatibility: PHP is platform-independent and runs on various
operating systems like Windows, Linux, and macOS, ensuring compatibility across
different environments.
6. Large Community and Documentation: A vast and active developer community
provides extensive online resources, tutorials, and documentation, making it easier to
find solutions and support.
7. Frameworks and CMS: Popular frameworks like Laravel and Symfony, as well as
content management systems like WordPress and Joomla, enhance rapid development
and offer pre-built modules.
8. Server-Side Scripting: PHP scripts run on the server, reducing the load on the client
side and enabling the generation of dynamic content and server-related tasks.
9. Community Support: Continuous contributions from the PHP community ensure regular
updates, security patches, and overall improvements.
Disadvantages of PHP
1. Inconsistency: PHP has inconsistencies in function names and parameter orders,
which can cause confusion for developers, especially when dealing with both older and
newer functions.
2. Security Concerns: PHP code can be vulnerable to security issues like SQL injection
and cross-site scripting (XSS) if not properly handled. Developers must follow best
practices to secure their applications.
3. Performance: Although PHP performs well for many web applications, it may not be as
fast as compiled languages like C or Java. However, recent versions have made
significant performance improvements.
4. Lack of Modern Features: Compared to newer programming languages, PHP may lack
some modern features. However, recent updates have introduced new features to
mitigate this concern.
5. Scalability Challenges: PHP can encounter scalability issues with large and complex
applications, requiring additional tools or frameworks to manage scalability effectively.
Purpose of PHP Cookies
Cookies are small pieces of data stored on the client side (browser) that are sent back to the
server with each subsequent request. In PHP, cookies are used to maintain state and store
user-specific information between page requests. They are often used for tracking user
sessions, storing user preferences, and personalizing user experiences.
To demonstrate how to create, retrieve, and delete cookies in PHP, let's go through a simple
example.
Setting a Cookie
To set a cookie in PHP, you use the setcookie() function. The basic syntax is:
Explanation
Function in PHP
Functions in PHP are blocks of reusable code that perform specific tasks. They help in
organizing code, making it more modular, easier to read, and maintainable. Functions in PHP
follow a similar syntax to other programming languages like C and JavaScript. Here's an
overview of how functions work in PHP:
Defining a Function
You can define a function in PHP using the function keyword followed by the function name
and a pair of parentheses. If the function takes parameters, you can list them inside the
parentheses. The function body is enclosed within curly braces {}.
Calling a Function
To execute a function and perform its tasks, you call it by its name followed by parentheses. If
the function takes parameters, you pass them inside the parentheses.
functionName($argument1, $argument2);
Let's create a simple PHP function that takes two numbers as parameters and returns their sum.
function addNumbers($num1, $num2) {
$sum = $num1 + $num2;
return $sum;
}
Functions in PHP can return values using the return statement. The returned value can be of
any data type, including integers, strings, arrays, or objects.
echo greet("John");
// Output: Hello, John!
By default, PHP functions pass parameters by value, meaning the original value remains
unchanged outside the function. However, you can pass parameters by reference using the &
symbol, allowing changes made within the function to affect the original variable.
$value = 5;
increment($value);
echo $value;
// Output: 6
Rules for declaring variables in php with ref to mysql
In PHP, variables are declared following certain rules and conventions, especially when
interacting with MySQL databases. Here's how these rules apply:
Variable Naming: Variable names in PHP used for MySQL interactions should adhere to the
general PHP variable naming rules. They must start with a letter or underscore (_), followed by
letters, numbers, or underscores. For clarity, choose descriptive names that reflect the purpose
of the variable.
$username = "user123";
$password = "pass456";
Case Sensitivity: PHP variable names are case-sensitive. However, MySQL database and
table names may vary in their treatment of case depending on the operating system and MySQL
configuration. It's generally advisable to maintain consistency in naming conventions to avoid
confusion.
$firstName = "John";
$FirstName = "Doe";
Reserved Keywords: Avoid using PHP reserved keywords and MySQL reserved words as
variable names. These include words like select, from, where, and, etc. Using reserved
keywords can lead to syntax errors or unintended behavior.
$select = "SELECT * FROM users"; // Avoid using reserved keywords
Dollar Sign Prefix: PHP variables must start with a dollar sign ($). However, when passing
variables to SQL queries, you omit the dollar sign and directly use the variable name within the
query to interpolate its value.
$query = "SELECT * FROM users WHERE username = '$username'";
SQL Injection Prevention: When using variables in SQL queries, it's crucial to sanitize user
inputs to prevent SQL injection attacks. Use prepared statements or parameterized queries with
placeholders to safely insert variables into SQL queries.
$stmt = $pdo->prepare("SELECT * FROM users WHERE username = ?");
$stmt->execute([$username]);
Data Types: PHP variables can hold various data types (e.g., strings, integers, arrays), while
MySQL columns have specific data types (e.g., VARCHAR, INT, DATE). Ensure that the PHP
variable type matches the MySQL column type when inserting or retrieving data from the
database.
$age = 25; // Integer
Following these rules ensures that PHP variables used in MySQL interactions are correctly
declared, named, and handled, contributing to the security, clarity, and reliability of your PHP
applications.
Each type of PHP interpreter has its own advantages and use cases. For example, standalone
interpreters are convenient for local development and testing, while embedded interpreters are
essential for serving dynamic web pages. Command-line interpreters are useful for scripting and
automation tasks, and virtual machine interpreters provide optimized performance for production
environments. The choice of interpreter depends on the specific requirements of the project and
the deployment environment.
Session in php
In PHP, a session is a way to store information across multiple pages or requests for a single
user. It allows you to maintain state and track user activity during a browsing session on a
website. Sessions are commonly used for tasks like user authentication, storing shopping cart
items, and tracking user preferences.
Purpose of Sessions:
1. Maintaining User State: Sessions enable the server to recognize and maintain state for
individual users as they navigate through a website. This allows for personalized
experiences and interactions.
2. User Authentication: Sessions are often used to manage user authentication, allowing
users to remain logged in across multiple pages without having to re-enter their
credentials.
3. Shopping Cart Management: Sessions can store information about items added to a
shopping cart, allowing users to browse different pages on an e-commerce site while
retaining their selected items.
4. Tracking User Activity: Sessions provide a mechanism for tracking user activity, such
as page views, clicks, and other interactions, which can be valuable for analytics and
reporting purposes.
Creating Sessions:
Sessions in PHP are managed using the session_start() function, which initializes a
session or resumes an existing one. Typically, you call session_start() at the beginning of
each PHP script that needs to access session data.
<?php
session_start(); // Start or resume the session
When session_start() is called, PHP checks if a session cookie exists in the user's
browser. If not, it generates a unique session ID and sends it to the browser in the form of a
cookie. This session ID is used to identify the user's session on subsequent requests.
Once a session is started, you can access session variables using the $_SESSION superglobal
array. Session variables are stored on the server and persist across multiple page loads until the
session is destroyed.
<?php
session_start(); // Start or resume the session
Destroying Sessions:
Sessions can be destroyed using the session_destroy() function, which removes all
session data associated with the current session. This is commonly used when logging out a
user or when a session expires.
<?php
session_start(); // Start or resume the session
It's important to note that simply calling session_destroy() only removes session data on
the server. The session cookie on the client side still exists until the browser is closed or the
cookie expires. To completely end a session, you may also need to unset session variables and
delete the session cookie manually.
Client-side scripting and server-side scripting are two different approaches to executing code in
web development, each serving distinct purposes and operating in specific contexts.
Client-Side Scripting:
Definition: Client-side scripting refers to the execution of scripts or code within the user's web
browser (the client). The scripts are downloaded from the server and run locally on the client's
machine.
Purpose:
Examples:
● Form Validation: Checking if a user has entered a valid email address or a required
field before submitting a form.
● Dynamic Content: Displaying real-time updates, such as live chat messages or stock
prices, without refreshing the page.
● User Interface Effects: Creating animations, transitions, and interactive elements, like
dropdown menus or sliders.
Server-Side Scripting:
Definition: Server-side scripting involves executing scripts or code on the web server before
delivering the final HTML output to the client's browser. The server processes the script,
generates dynamic content, and sends the result to the client.
Purpose:
Examples:
● Execution Environment: Client-side scripts run in the user's browser, while server-side
scripts run on the web server.
● Interactivity: Client-side scripting enables immediate user interaction without requiring
server communication, while server-side scripting involves communication with the
server for dynamic content generation.
● Security: Client-side scripts are visible and accessible to users, making them vulnerable
to manipulation, while server-side scripts are executed securely on the server, reducing
the risk of unauthorized access or tampering.
Both client-side and server-side scripting have their roles in web development, and a
combination of both is often used to create dynamic, interactive, and responsive web
applications.
In PHP, the GET and POST methods are two HTTP request methods used to send data from a
web form to a server. They are commonly used in web development for processing form
submissions and handling user input. Here's an explanation of each method and their usage in
PHP:
GET Method:
● Purpose: The GET method is used to request data from a specified resource. It sends
data as part of the URL query string, visible in the browser's address bar.
● Usage: Typically used for retrieving data from the server, such as fetching search results
or displaying information based on parameters.
● Data Encoding: Data sent via GET method is appended to the URL in the form of
key-value pairs, separated by & symbols and URL-encoded.
● Security Considerations: Because data is visible in the URL, GET requests should not
be used for sensitive information like passwords, as they are visible in browser history
and server logs.
Example:
<form method="get" action="process.php">
<input type="text" name="search" placeholder="Search">
<button type="submit">Search</button>
</form>
<?php
if (isset($_GET['search'])) {
$searchTerm = $_GET['search'];
// Process search query
}
?>
POST Method:
● Purpose: The POST method is used to send data to a server to create or update a
resource. It sends data in the HTTP request body, not visible in the URL.
● Usage: Typically used for submitting forms, uploading files, or sending large amounts of
data that should not be visible in the URL.
● Data Encoding: Data sent via POST method is encoded as key-value pairs in the HTTP
request body, not visible to the user.
● Security Considerations: POST requests are more secure than GET requests for
transmitting sensitive data, as they are not visible in the URL.
Example:
<form method="post" action="process.php">
<input type="text" name="username" placeholder="Username">
<input type="password" name="password" placeholder="Password">
<button type="submit">Login</button>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $_POST['username'];
$password = $_POST['password'];
// Validate username and password
}
?>
In PHP, both $_GET and $_POST superglobal arrays are used to access data sent via GET and
POST methods, respectively. It's essential to validate and sanitize user input received through
both methods to prevent security vulnerabilities like SQL injection and cross-site scripting (XSS).
php code to find the length of a string
<?php
$string = "Hello, world!";
$length = strlen($string);
echo "The length of the string '$string' is: $length";
?>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully<br>";
// Insert a record
$insert_sql = "INSERT INTO my_table (firstname, lastname, email) VALUES ('John', 'Doe',
'john.doe@example.com')";
$conn->close();
?>
<?php
// Function to find and print the largest of three integers
function findLargest($a, $b, $c) {
// Compare the integers
if ($a >= $b && $a >= $c) {
$largest = $a;
} elseif ($b >= $a && $b >= $c) {
$largest = $b;
} else {
$largest = $c;
}
// Example usage
$num1 = 10;
$num2 = 25;
$num3 = 15;
<?php
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Example usage
$new_username = "newuser";
$new_password = "newpassword123";
addUser($conn, $new_username, $new_password);
Using mysqli
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully<br>";
// Perform a query
$sql = "SELECT id, firstname, lastname FROM my_table";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// Output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} else {
echo "0 results";
}
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "my_database";
try {
// Create connection
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// Set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully<br>";
// Perform a query
$stmt = $conn->prepare("SELECT id, firstname, lastname FROM my_table");
$stmt->execute();
foreach($stmt->fetchAll() as $row) {
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
}
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
// Close the connection (PDO does this automatically at the end of the script)
$conn = null;
?>
Explanation:
Note:
● Ensure that your database (my_database) and table (my_table) exist and have the
fields id, firstname, and lastname.
● Replace "localhost", "root", "", and "my_database" with your actual database
host, username, password, and database name.
These examples provide a simple way to connect to a MySQL database, execute a query, and
fetch results using both mysqli and PDO.
<label for="email">Email:</label><br>
<input type="text" id="email" name="email"><br><br>
<label for="password">Password:</label><br>
<input type="password" id="password" name="password"><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>
PHP ka code
<?php
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form data
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
// Display the password (In a real application, you should handle the password securely)
if (!empty($password)) {
echo "Password: " . htmlspecialchars($password) . "<br>";
} else {
echo "Password is required.<br>";
}
}
?>
Explanation
1. HTML Form:
○ The form collects the username, email, and password from the user.
○ The form uses the POST method to submit the data to process_form.php.
2. PHP Script (process_form.php):
○ Checks if the form is submitted using $_SERVER["REQUEST_METHOD"] ==
"POST".
○ Retrieves the form data using $_POST['username'], $_POST['email'], and
$_POST['password'].
○ Validates the username field to ensure it is not empty.
○ Validates the email field to ensure it is not empty and correctly formatted using
filter_var($email, FILTER_VALIDATE_EMAIL).
○ Displays appropriate messages based on the validation results.
Need of mysql
MySQL is a popular open-source relational database management system (RDBMS). It is
widely used in web applications and other software to store and manage data. Here are some
key reasons for using MySQL:
1. Open Source: MySQL is freely available and can be modified to suit specific
requirements.
2. High Performance: It is designed to handle a large amount of data efficiently.
3. Scalability: MySQL can manage a small amount of data and scale up to handle large
databases.
4. Reliability: It ensures data integrity and supports features like ACID transactions to
guarantee reliable data handling.
5. Support for Large Databases: MySQL can handle databases with millions of records.
6. Ease of Use: It has a simple and intuitive interface, making it easy to learn and use.
7. Cross-Platform: MySQL can run on various operating systems including Windows,
Linux, and macOS.
8. Extensive Documentation: There is comprehensive documentation available, along
with a large community for support.