CHAPTER 6
Server side scripting
1
INTRODUCTION
Server-side scripting language, which means that
the scripts are, executed on the server, the
computer where the Web site is located.
is a web server technology in which a user's request
is fulfilled by running a script directly on the web
server to generate dynamic web pages.
It is usually used to provide interactive web sites
that interface to databases or other data stores.
This is different from client-side scripting where
scripts are run by the viewing web browser.
It is the ability to highly customize the response
based on the user's requirements, access rights, or
2
queries into data stores
CONT’D..
A server script can do:-
Dynamically edit, change or add any content to a
Web page
Respond to user queries or data submitted from
HTML forms
Access any data or databases and return the result
to a browser
Customize a Web page to make it more useful for
individual users
Provide security since server code cannot be
viewed from a browser 3
SERVER SIDE SCRIPTING WITH PHP
PHP is an acronym for "PHP: Hypertext Preprocessor"
PHP is a widely-used, open source scripting language
PHP scripts are executed on the server
PHP is free to download and use
PHP is an amazing and popular language!
It is powerful enough to be at the core of the biggest
blogging system on the web (WordPress)!
It is deep enough to run the largest social network
(Facebook)!
It is also easy enough to be a beginner's first server
side language!
4
USE OF PHP
PHP performs system functions, i.e. from files on a
system it can create, open, read, write, and close
them.
PHP can handle forms, i.e. gather data from files,
save data to a file, thru email you can send data,
return data to the user.
Using php, it is possible to add, delete, and modify
elements within our database.
It helps to assign sessions and cookies for privacy.
Using PHP, we can restrict users to access some
pages of the website.
It can encrypt data and so mores
5
SESSION MANAGEMENT
It is the process of securing multiple requests to a
service from the same user or entity
In many cases, a session is initialized by
authenticating a user or entity with factors such as
a password
Once the user is authenticated, subsequent
requests authenticate the session as opposed to the
user themselves
6
CONT’D…
Session Id Users prove they own a session by submitting
authentication parameters with each request that
typically include a session id and other factors such as a
nonce. Session ids are designed to be long and random
such that it is infeasible to guess them.
Transport Session management is essentially a process
of providing secrets to authenticated users such as a
session id and having them pass it back to you. As such,
cryptographically secure network communications are
required to implement secure session management.
Cookies The security of clients is a concern for session
management. In the case of a web browser, session ids
may be stored in secure cookies. In some cases, browsers
can be tricked into giving up their session credentials with
7
attacks such as DNS spoofing. As such, consideration of
cookie security is within the scope of session
CONT’D…
Session Expiry Sessions are designed to be
temporary objects that expire. Their life is typically
extended with each new request with a maximum
age that can't be exceeded.
Session Resources Session management may be
targeted by denial of service attacks that flood
services with requests to create new sessions. As
such, session management is ideally resource light.
Detecting Anomalies Session management may
include features to detect anomalies such as brute
force guesses of session ids or denial of service
attacks. In some cases, session management may
prevent users from creating multiple sessions from
the same IP. For practical reasons of usability, this 8
may be allowed up to some limit.
DATABASE DRIVEN WEB
APPLICATIONS
Database driven web applications are one significant
methodology that can be used to empower end users to
change content dynamically without knowledge of HTML or
an HTML editor
Here are some key points to understand in order to choose a
web design format that suits your goals:
Dynamic Vs. Static Websites
Static website:
This website does not change every time the browser loads
a page
If a user clicks a button, nothing changes on the layout and
content of the page
The only changes occur when the user loads a new page or
when the admin loads another page on the web browser
9
The content is stored on the web file system and it will
always be presented in the same format
Dynamic website:
These pages change every time they are loaded
without the webmaster having to make the changes
If a user clicks on an image or text, some changes
are observed on the particular page
The fact that the content is stored outside the web
file system makes it easier to manage and you can
manipulate data quickly
10
DATABASE DRIVEN WEBSITE
A database driven website is the best example of a
dynamic website
The web page grabs information from your database
and inserts the same on the web page every time it
is loaded
In case there are any changes to the information in
the database, the web page (which is connected to
the database through programming) will also change
automatically
These websites are more effective and they are
commonly used for large industries.
11
EXAMPLE OF DATABASE DRIVEN
WEBSITE
E-Commerce platforms: These businesses leverage
data driven websites because of the expected changes in
prices, offers and services. This guarantees the
information internet users find is always fresh and up-to-
date.
Content Management Systems (CMS): If the website
is going to use a CMS then it is database driven
Users can easily update content on the website even
without the need for any specialized programming skills
It include WordPress and Joomla and they have an easy-
to-use editor to allow publishing of content, editing and
deleting
Blogs: Most blogs and online community forums are
database driven because they involve regular updates by
users 12
Whether people are leaving comments or liking a website
there is immediate change on the page.
DATABASE DRIVEN WEBSITE AND
COST
If you are building a database driven website, the cost
will be higher for various reasons:
Database costs: Dynamic websites require databases
be it MySQL Community Server, Oracle Express Edition
or any other. If you are creating an e-commerce
website, you need a database to support shopping
carts, discussion forums, registration systems and
much more. Depending on your hosting package, you
might not get a database allowance and you might
have to upgrade for better performance. This comes at
a higher cost.
Custom database design: If a website requires a
database design built specifically to suit it the cost will
go up. Such factors such as efficiency of data structure,
13
functionality and development lead to higher costs of
the website
CONT’D…
Database connectivity: Before the website becomes
operational, more codes are needed to optimize the database
and make it possible to process, retrieve and manipulate
data. This adds to the cost of the database driven website.
Back-end administration: Database driven websites end
up costing more due to the needed technical database
services. Whether the owner goes for in-house or remote
database administration, these services add to the cost of the
website.
Initial database population: Setting up the database also
calls for technical skills irrespective of whether the database
platform is custom-design or pre-built. Initial database
population by a database administrator increases the cost of
these websites.
Backups: If there is a database, backup services are
invaluable. Backups come with a cost and in most cases you 14
will have to depend on more than one; both offline media
storage and cloud backup for instance.
ADVANTAGE OF DATABASE DRIVEN
WEBSITE
It is easier and faster to update content. A few clicks
are all the webmaster needs to update the content.
Changes are made almost in real-time.
It is ideal for an ecommerce site where different
products need to be added, prices changes and offers
introduced. No need for specialized HTML knowledge or
expertise to change content on the website.
High scalability: Every business grows with time and
a database driven website offers room for growth.
Changing graphics, layout or interactivity can be done
anytime.
Reduced chances for error: Physical data entry by
employees is bound to lead to errors, which can lead to
downtime, bugs and other problems. Rectifying such
15
problems on data-driven websites is easy and this
improves user experience.
Question?
The End!!!
16