You are on page 1of 44

SERVER SIDE PROGRAMMING

By Dr. Babaousmail Hassen

Lecturer at Binjiang College of NUIST


YOUR INTRODUCTION
CLASS

 Class time will be used for short lectures, design examples,


and class exercises.
 Class attendance is expected and students are responsible
for all material covered in class. Missed work will receive a
grade of zero.
 Class disruption (cell phones, sleeping, talking, etc.) during
class will not be tolerated. A warning will be given on the
first instance and you will be asked to leave the class on
any subsequent instances.
CLASS

Lectures:

24 Hours.

Practical classes:
36 Hours.
ASSESSMENT METHOD

1. Your Project 25%

Total of 100 2. Exam: Mid Term + Final 50%


points
3. Presentation 10%

You will be informed 4. Assignments 10%


In case of any changes.

5. Attendance 5%
REFERENCE BOOKS
WHAT IS SERVER-SIDE SCRIPTING?

Server-side scripting is a programming method to


create dynamic web pages

It runs software on the server rather than the browser


to create dynamic web pages.

Languages used for these tasks are normal


programming languages which include Perl, PHP,
JSP, Ruby, ColdFusion, and Python, etc.
DYNAMIC AND STATIC WEB PAGES

 Static Web pages display the exact same


information whenever anyone visits it.

 Dynamic Web pages are capable of producing


different content for different visitors from
the same source code file.
DIFFERENCES BETWEEN CLIENT-
SIDE AND SERVER-SIDE SCRIPTING

1) Client-side scripting used to run scripts. It is


usually a browser.
• The processing takes place on the users
computer.
• The source code is transferred from the web
server to the users computer over the internet
and run directly in the browser.
DIFFERENCES BETWEEN CLIENT-
SIDE AND SERVER-SIDE
SCRIPTING
2) Server-side environment runs a scripting
language in a web server.
• It is usually used to provide interactive web
sites that interface to databases or other data
stores on the server.
• Server-side scripting response based on the
user's requirements, queries, etc.
WHY SERVER-SIDE SCRIPTING IS
IMPORTANT

 User does not need to download plugins like Java or


Flash.
 User can create one template for the entire website.
 The site can use a content management system which
makes editing simpler.
 Generally quicker to load than client-side scripting.
 User is able to include external files to save coding.
 Scripts are hidden from view so it’s more secure, users
only see the HTML output
REQUEST / RESPONSE CYCLE

You enter http://server.com into your browser’s address bar.


Your browser looks up the IP address for server.com.
Your browser issues a request for the home page at server.com.
The request crosses the Internet and arrives at the server.com
web server.
The web server, having received the request looks for the web
page on its hard disk.
The web page is retrieved by the server and returned to the
browser.
Your browser displays the web page.
PHP & MYSQL

PHP is a server-side scripting language.

For PHP scripts to retrieve information


from a database, you must first have a
database.

That’s where MySQL comes in. MySQL is


a relational database management system
(RDMS).
PHP &HTML

PHP extends HTML pages by adding


server-executed code segments to HTML
pages.

The output of the execution of the PHP code


is merged into the HTML page.
PHP

 PHP is an Open Source product. You have access to the


source code. You can use it, alter it, and redistribute it all
without charge.
  PHP originally stood for Personal Home Page, but was
changed in line with the GNU recursive naming
convention and now stands for PHP Hypertext
Preprocessor.
 The home page for PHP is available at
http://www.php.net.
THE HISTORY OF PHP

 Server-side scripting language


– PHP = Personal Home Page tools.
– Somewhat like C but much higher level, OOP
model added later.
– PHP is the most widely used scripting language for web
programming, used today with many commercial sites.
– Runs on both Unix and Windows platforms, with most
web servers.
THE HISTORY OF PHP

Rasmus Lerfdorf
Not a trained computer
scientist
Consultant building
dynamic web sites - got
tired of doing the same
thing over and over in C
STRENGTHS OF PHP

 Some of PHP’s main competitors are Perl, Microsoft Active Server


Pages (ASP), Java Server Pages (JSP), and Allaire ColdFusion.
 In comparison to these products, PHP has many strengths, including
the following:
High performance
Interfaces to many different database systems
Built-in libraries for many common Web tasks
Low cost
Ease of learning and use
Portability
Availability of source code
PERFORMANCE

 PHP is very efficient. Using a single


inexpensive server, you can serve millions of
hits per day. Benchmarks published by Zend
Technologies (http://www.zend.com) show
PHP outperforming its competition.
PHP & DATABASE INTEGRATION

 PHP has native connections available to many


database systems. In addition to MySQL, you can
directly connect to PostgreSQL, mSQL, Oracle,
dbm, filePro, Hyperwave, Informix, InterBase, and
Sybase databases, etc.
BUILT-IN LIBRARIES

 Because PHP was designed for use on the Web, it


has many built-in functions for per-forming many
useful Web-related tasks. You can generate GIF
images on-the-fly, connect to other network
services, send email, work with cookies, and
generate PDF documents, all with just a few lines
of code.
COST

 PHP is free. You can download the latest version


at any time from http://www.php.net for no
charge.
LEARNING PHP

 The syntax of PHP is based on other


programming languages, primarily C and
Perl. If you already know C or Perl, or a C-
like language such as C++ or Java, you will
be productive using PHP almost
immediately.
PORTABILITY

 PHP is available for many different operating


systems. You can write PHP code on the free Unix-
like operating systems such as Linux and FreeBSD,
commercial Unix versions such as Solaris and
IRIX, or on different versions of Microsoft
Windows.

 Your code will usually work without


modification on a different system running PHP.
PHP SOURCE CODE

 You have access to the source code of PHP.


Unlike commercial, closed-source products, if
there is something you want modified or added
to the language, you are free to do this.
MYSQL

MySQL (pronounced My-Ess-Que-Ell) is a very


fast, robust.
MySQL is one of the most popular free and open
source database engines in the market place.
MySQL powers Facebook, Yahoo!, and millions
of other dynamic web sites.
A database enables you to efficiently store,
search, sort, and retrieve data.
MYSQL

The MySQL server controls access to your data to


ensure that multiple users can work with it
concurrently, to provide fast access to it, and ensure
that only authorized users can obtain access.
MySQL is a multi-user server. It uses SQL
(Structured Query Language), the standard database
query language worldwide.
MySQL is now available under an Open Source
license, but commercial licenses are also available if
required.
SQL QUERIES

INSERT INTO users VALUES ('Smith',


'John', 'jsmith@mysite.com');

SELECT surname,firstname FROM users


WHERE email='jsmith@mysite.com';
STRENGTHS OF MYSQL

Some of MySQL’s main competitors are


PostgreSQL, Microsoft SQL Server, and Oracle.
MySQL has many strengths, including the following:

High performance
Low cost
Easy to configure and learn
Portable
The source code is available
Performance

 MySQL is definitely fast. You can see the


developers’ benchmark page at the
https://www.mysql.com Web site. Many of
these benchmarks show MySQL to be orders
of magnitude faster than the competition.
LOW COST

 MySQL is available at no cost, under an


Open Source license, or at low cost under a
commercial license if required for your
application.
EASE OF USE

Most modern databases use SQL. If you have


used another RDBMS, you should have no
trouble adapting to this one.
PORTABILITY

MySQL can be used on many different Unix


systems as well as under Microsoft Windows.
SOURCE CODE

Like PHP, you can obtain and modify the


source code for MySQL.
WINDOW INSTALLATION

Wamp Server (Wamp stands for Windows,


Apache, MySQL, and PHP) is a free, all-in-one
program that includes built-in copies of recent
versions of the Apache web server, PHP, and
MySQL.
STEP-1

Download the latest version from the Wamp Server web site.
http://www.wampserver.com/en

After downloading the


file (as of this writing,
Wamp Server 2.0g is
about 16MB in size),
double-click it to launch
the installer, as shown
in Figure above.
STEP-2

The installer will prompt you for a location to install


Wamp Server. The default of c:\wamp shown in this
Figure is an ideal choice for most purposes, but if you
want to change location, feel free to specify your preferred
location.
STEP-3

At the end of the


installation, Wamp Server
will ask you to choose
your default browser. If
you have Firefox installed
it will ask if you like to
use it as your default
browser. If you answer
No, or have a different
browser installed, it will
ask you to select the
browser you want to use.
STEP-4

As Wamp Server is installed it


fires up its built-in copy of the
Apache HTTP Server, a
popular web server for PHP
development. Windows will
display a security alert at this
point, like the one in this Figure,
since the web server attempts to
start listening for browser
requests from the outside world.
STEP-5

Next, as shown in this Figure,


the Wamp Server installer will
ask your SMTP server and
email address. Type in your
email address, and if you can
remember your Internet
Service Provider’s SMTP
server address, type it in too.

You can always leave the


default value, and set it
manually when you need to
send email using a PHP
script.
STEP-6

Once the installation is complete,


you open Wamp Server. An icon
will appear in your Windows
System Tray. Click on it to see the
Wamp Server menu shown in this
Figure.
By default, your server can only be
accessed by web browsers running
on your own computer. If you click
the Put Online menu item, your
server will become accessible to
the outside world.
STEP-7

To test that Wamp Server is working properly, click the Local host menu
item at the top of the Wamp Server menu. Your web browser will open to
display your server’s home page, shown in this Figure.

When you’re done working with Wamp Server, you can shut it down (along with its
built-in servers) by right-clicking the System Tray icon and choosing Exit. When
you’re next ready to do some work on a database driven web site, open it again.
SUMMARY

What do we have learned today ?


Class schedule, exam and grades.
Introduction and basics of server side scripting.
Installation of wamp server.

ACKNOWLEDGEMENTS
I acknowledge all the authors of book and Web Pages whose
contents are being used in preparation of this lecture.

You might also like