WBP 5 Sem Unit 01 & 02
WBP 5 Sem Unit 01 & 02
WBP 5 Sem Unit 01 & 02
Recommended Books
UNIT-01 :
PART –A : Introduction to
Web Application
Topic -1
Software applications(Php,Asp,Jsp,Python,Perl,etc)
Web pages (Javascript,VB script,php etc)
FEATURES
❑ Ease of use: scripting languages are intended to be
very
fast to pick up
SCRIPTING
CLIENT-SIDE SEVER-SIDE
SERVER SIDE SCRIPTING
❑ Server side scripting is used to create dynamic
pages based a number of conditions when the
users browser makes a request to the server
2. Your scripts are hidden from view. Users only see the HTML output,
even when they view the source.
Disadvantages
The scripts can be used by attackers to gain access
to the server. Because the scripts respond to URL
input, changing the URL to something that exploits a
security hole can give the user server access,
sometimes even as root.
CLIENT-SIDE SCRIPTING
❑ Client side scripting is used when the users
browser already has all the code and the page is
altered on the basis of the users input.
users' actions
• Execute quickly because they don't require a trip to the server
•May improve the usability of Web sites for users whose
browsers support scripts
Can give developers more control over the look and behavior
•
2. Different browsers and browser versions support scripts differently, thus more
quality assurance testing is required.
3.More development time and effort might be required (if the scripts are not already
available through other resources).
4. Developers have more control over the look and behavior of their Web widgets;
however, usability problems can arise if a Web widget looks like a standard control
but behaves differently or vice-versa
Web Server
WEB SERVERS
40
WEB SERVERS
Access Control
▪ A Web server may limit which users can access
certain resources. Access control requires a
combination of authentication and
authorization.
➢ Authentication identifies the user who originated the
request.
➢ Authorization determines which users have access
to a particular resource.
WEB SERVERS
AUTHENTICATION
▪ Most client-server systems authenticate a user by asking for
a name and password.
AUTHORIZATION
▪ To control access to Web resources, the server must
employ an authorization policy.
▪ A policy typically expressed in terms of an access control
list that enumerates the users who are granted or denied
access to the resources.
▪ In addition to checking the user name, the server may
allow or deny access to the resource based on other
information associated with the HTTP request, such as
the host name or IP address of the requesting client.
▪ Authenticating HTTP requests can impose a heavy load
on the Web server.
Type of web servers:-
Introduction to PHP
PHP Introduction
In PHP, we use // to
make a single-line
comment or /* and */ to
make a large comment
block.
DATA TYPES IN PHP
Data type Description
int, integer Whole numbers (i.e., numbers without a decimal point).
float, double Real numbers (i.e., numbers containing a decimal point).
string Text enclosed in either single ('') or double ("") quotes.
bool, Boolean True or false.
array Group of elements of the same type.
object Group of associated data and methods.
Resource An external data source.
NULL No value.
$cities[0] = “London”;
$cities[1] = “Bath”;
$cities[2] = “Bristol”;
?>
- an array can be indexed using a string value for the index (called
associative array or hash) and are useful in situations where there is a need
to collect different types of data into one array. (e.g. $userInfo [“name”] =
“Kevin”; )
$modules = array(
“ISD”=>array(
“Joe”,
“Tim”,
Data Types (3)
o objects : are another composite data type fully supported by php.
- php supports standard object-oriented (OO) methodologies and
techniques such as
inheritance - the ability to derive new classes from existing ones and
inherit or override their attributes and methods.
encapsulation - the ability to hide data from users of the class (the
public, protected and private keywords.)
special methods - for instance, code that is automatically run when
a object is created (constructor) or destroyed (destructor).
polymorphism – overloading a function so that a function call will
behave differently when passed variables of different type.
- a good introducton to OO programming using php can be found at
> Arithmetic
> Assignment
> Comparison
> Logical
PHP Operators
Airthmetic Operators with Examples
1. Addition :
2. Substraction :
3. Multiplication
4. Division
5. Modulus:
6. Increment :
a) Pre-Increment :
b) Post-increment:
c) Pre-decrement:
d) Post-decrement
Assignment Operators
The PHP assignment operators are used with numeric values to write a value to a
variable.
The basic assignment operator in PHP is "=". It means that the left operand gets set to the
value of the assignment expression on the right.
Assignment Operators with Examples
1. x=y
2. x += y
3. x -= y
4. x *= y
1. x /= y
2. x %= y
PHP Comparison Operators
Comparison Operators with Examples
1. ==
2. 2. === Identical
9. <=> Spaceship
PHP Logical Operators
Logical Operators with Examples
1. and
2. 2. or
1. 3. xor
4. &&
5. ||
6. !
PHP Conditional Statements
> Very often when you write code, you want to
perform different actions for different decisions.
> You can use conditional statements in your
code to do this.
> In PHP we have the following conditional
statements...
PHP Conditional Statements
> if statement - use this statement to execute
some code only if a specified condition is true
> if...else statement - use this statement to
execute some code if a condition is true and
another code if the condition is false
> if...elseif....else statement - use this statement
to select one of several blocks of code to be
executed
> switch statement - use this statement to select
one of many blocks of code to be executed
IF Statement
The following example will output "Have a nice
weekend!" if the current day is Friday:
Nested if Statement
if....else
Use the if....else statement to execute some code
if a condition is true and another code if a
condition is false.
PHP Conditional Statements
Dimensions: Dimensions
of multidimensional array indicates
the number of indices needed to select an element. For
a two dimensional array two indices to select an
element.
Creating Associative Arrays In PHP
The arrays we’ve seen so far have been numerically
indexed, meaning that they use an integer index position
as the key.
<?php
$str = "Visit Jims Rohini Sector 05";
$pattern = "/jims/i";
echo preg_match($pattern, $str);
?>
Using preg_match_all()
<?php
$str = "We always pretend that we are listening
the lecture,but we are lost in day dreaming";
$pattern = "/we/i";
echo preg_match_all($pattern, $str);
?>
Using preg_replace()