0% found this document useful (0 votes)
410 views35 pages

Chapter 2 Server-Side Scripting Overview

Server-side scripting allows dynamic web page generation on the server. It can access databases and other server resources to retrieve and insert content. Common server-side languages include PHP, ASP, and JSP. PHP files contain HTML markup, text, and PHP code. The PHP code is executed on the server and generates an HTML response. This allows dynamic content generation based on user inputs, database queries, and server-side logic.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
0% found this document useful (0 votes)
410 views35 pages

Chapter 2 Server-Side Scripting Overview

Server-side scripting allows dynamic web page generation on the server. It can access databases and other server resources to retrieve and insert content. Common server-side languages include PHP, ASP, and JSP. PHP files contain HTML markup, text, and PHP code. The PHP code is executed on the server and generates an HTML response. This allows dynamic content generation based on user inputs, database queries, and server-side logic.
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1/ 35

CHAPTER 2

Server-Side
Scripting Overview
What are client-Side Scripting
Languages ?
• web browsers executes client side scripting. It is use
when browsers has all code. Source code used to
transfer from web server to user’s computer over
internet and run directly on browsers.
• It allows for more interactivity. It usually performs
several actions without going to user. It cannot be
basically used to connect to databases on web server.
What are Server-Side Scripting
Languages ?
 Web servers are used to execute server side scripting.
They are basically used to create dynamic pages. It can
also access the file system residing at web server.
Server-side environment that runs on a scripting
language is a web-server.
 Scripts can be written in any of a number of server-side
scripting language available. It is used to retrieve and
generate content for dynamic pages. When you need to
store and retrieve information a database will be used to
contain data. It can use huge resources of server.
Difference b/w client side & server side
scripting :
CLIENT SIDE SCRIPTING SERVER SIDE SCRIPTING
Source code is visible to user. Source code is not visible to user because it’s
output of server side is a HTML page.
It usually depends on browser and it’s In this any server side technology can be use and
version. it does not depend on client.
It runs on user’s computer. It runs on web server.
There are many advantages link with this like The primary advantage is it’s ability to highly
faster. response times, a more interactive customize, response requirements, access rights
application. based on user.

It does not provide security for data. It provides more security for data.

It is a technique use in web development in It is a technique that uses scripts on web server to
which scripts runs on clients browser. produce a response that is customized for each
clients request.

HTML, CSS and javascript are used. PHP, ASP, Python, Java, Ruby are used.
Static vs. Dynamic Website
 A static website is one that is written in
HTML only.
 It has no connection to any database.
 A dynamic website is written using more
complex code and can do a lot more.
 It can read and send data into a database
in the server.
Dynamic Content

 You might have probably heard that “using


PHP you can create dynamic web sites”. To
understand what “dynamic” means here, let’s
take a look at welcome.html and
welcome.php.
welcome.html
<html>
<head>
<title>Welcome to Our Web Site</title>
</head>
<body>
<h1>Welcome!</h1>
<p>Rest goes here...</p>
</body>
</html>
welcome.php
<html>
<head>
<title>Welcome to Our Web Site</title>
</head>
<body>
<h1>
<?php
if (date('G') < 12) {
echo 'Good Morning!';
} else {
echo 'Welcome!';
}
?>
</h1>

<p>Rest goes here...</p>

</body>
</html>
 No matter what’s the current time of the day, if
you request welcome.html, you would always
see Welcome! as the heading. But if you request
welcome.php before 12 noon, you would see the
heading as Good Morning! and Welcome!, if it is
after 12 (date() function uses server’s time and it
may be different from your PC’s time).
 Here welcome.html has a static behavior
because it delivers same content always. But
welcome.php has a dynamic behavior
because the content it delivers changes
according to the time of the day. You can
improve this file and have different greetings
for different time periods. As illustrated in this
example, PHP can be used to build dynamic
content that is based on the context. You
would experience the real benefits of PHP’s
dynamic behavior when you create database
driven web applications.
What It Can Do?
 Dynamically edit, change, or add any content of
a Web page
 Respond to user queries and form data
 Access databases and return the result to a
browser
 Access files and return the result to a browser
 Transform XML data to HTML data and return
the results to a browser
What It Can Do? Cont.…..

 Customize a Web page to make it more


useful for individual users
 Provide security and access control to Web
pages
 Tailor your output to different types of
browsers
How It Works?
Static HTML

 The most basic type of web page is a


completely static, text-based one, written
entirely in HTML.
Client-Side Technologies
 The most common additions to plain HTML are on
the client side. These add-ons include formatting
extensions, such as Cascading Style Sheets
(CSS) and Dynamic HTML; client-side scripting
languages,
 such as JavaScript; VBScript; Java applets; and
Flash. Support for all these technologies is (or is
not, as the case may be) built into the web
browser. They perform the tasks described in
Table 2-1, with some overlap.
 Unfortunately, the best thing about client-side
technologies is also the worst thing about them:
They depend entirely on the browser. Wide
variations exist in the capabilities of each browser
and even among versions of the same brand of
browser.
 Individuals can also choose to configure their own
browsers in awkward ways: Some people disable
JavaScript for security reasons, for example, which
makes it impossible for them to view sites that use
JavaScript incorrectly or with little care.
Server-Side Scripting
 Client-side scripting is the beautiful, eye-catching part of
web development. In contrast, server-side scripting is
invisible to the user.
 Server-side web scripting is mostly about connecting web
sites to backend servers, processing data and controlling
the behavior of higher layers such as HTML and CSS. This
enables the following types of two-way communication:
 Server to client: Web pages can be assembled from
backend-server output.
 Client to server: Customer-entered information can be
acted upon.
 Common examples of client-to-server interaction
are online forms with some drop-down lists
(usually the ones that require you to click a
button) that the script assembles dynamically on
the server.
 Server-side scripting products consist of two
main parts: the scripting language and the
scripting engine (which may or may not be built
into the web server). The engine parses and
interprets pages written in the language.
What Is Server-Side Scripting Good

For?
Server-side scripting languages such as PHP perfectly serve most
of the truly useful aspects of the web, such as the items in this list:
 Content sites (both production and display)
 Community features (forums, bulletin boards, etc)
 E‑mail (web mail, mail forwarding, and sending mail from a web
application)
 Customer-support and technical-support systems
 Advertising networks
 Web-delivered business applications
 Surveys, polls, and tests
 Filling out and submitting forms online
 Catalog, brochure, and informational sites
 Games (for example, chess) with lots of logic
but simple/static graphics
 Any other application that needs to connect a
backend server (database, Lightweight
Examples of Server-Side
Scripting Language
 PHP
 ASP
 JSP
 Python
PHP
 PHP stands for PHP: Hypertext Preprocessor
 PHP scripts are executed on the server
 PHP supports many databases
 PHP is an open source software: free to download
and use.
 The syntax of PHP is almost similar to C and Java.
 The goal of PHP is to allow web developers to
write dynamically generated pages quickly.
 PHP is a server scripting language, and a
powerful tool for making dynamic and
interactive Web pages.
 PHP is a widely-used, free, and efficient
alternative to competitors such as Microsoft's
ASP.
 PHP 7 is the latest stable release.
PHP Files

 PHP files can contain text, HTML tags and


scripts
 PHP files are returned to the browser as plain
HTML
 PHP files have a file extension of ".php"
PHP Requirements

 PHP Program
 MySQL Database
 Apache Server
Basic PHP Syntax
• A PHP scripting block always starts with <?php and
ends with ?>.
• A PHP scripting block can be placed anywhere in the

document.
• There are two basic statements to output text with PHP:

echo and print.


• Each code line in PHP must end with a semicolon.

• The semicolon is a separator and is used to

distinguish one set of instructions from another.


Example PHP Syntax
 <html>
 <body>
 <?php
 echo "Hello World";
 ?>
 </body>
 </html>
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!
What is a PHP File?

 PHP files can contain text, HTML, CSS,


JavaScript, and PHP code
 PHP code is executed on the server, and the
result is returned to the browser as plain
HTML
 PHP files have extension ".php"
What Can PHP Do?
 PHP can generate dynamic page content
 PHP can create, open, read, write, delete, and close
files on the server
 PHP can collect form data
 PHP can send and receive cookies
 PHP can add, delete, modify data in your database
 PHP can be used to control user-access
 PHP can encrypt data
 With PHP you are not limited to output HTML. You
can output images, PDF files, and even Flash movies.
Why PHP?

 PHP runs on various platforms (Windows,


Linux, Unix, Mac OS X, etc.)
 PHP is compatible with almost all servers
used today (Apache, IIS, etc.)
 PHP supports a wide range of databases
 PHP is free. Download it from the official PHP
resource: www.php.net
 PHP is easy to learn and runs efficiently on
the server side
Summary
 Client-side scripting can be visually attractive
and quickly responsive to user inputs, but
anything beyond the most basic HTML is subject
to browser variation. Static client-side scripts also
require more developer time to maintain and
update, because pages cannot be dynamically
generated from a constantly changing data store.
Server-side programming and scripting
languages, such as PHP, can connect databases
and other servers to web pages.

You might also like