Phpmodule 1
Phpmodule 1
Phpmodule 1
Introduction
Internet is a global communication system that links together thousands of
individual networks. It allows exchange of information between two or more
computers on a network.
WWW stands for World Wide Web. A technical definition of the World
Wide Web is: all the resources and users on the Internet that are using the
Hypertext Transfer Protocol (HTTP). The World Wide Web is the universe of
network-accessible information, a representation of human knowledge. In
simple terms, The World Wide Web is a way of exchanging information
between computers on the Internet, tying them together into a vast collection of
interactive multimedia resources.
Web consists of billions of clients and server connected through wires and
wireless networks. A desktop computer requesting for information is termed
as Client. The computer serving information from a central location is
termed as server.
The web clients make requests to web server. The web server receives the
request, finds the resources and returns the response to the client. The client
uses web browser to send request to the server. When a server answers a
request, it usually sends some type of content (file) to the client. The server
often sends response to the browser.
Files that travel across the largest network in the world, the Internet, and carry
information from a server to a client that requested them are called Web Pages.
The person who develops these web pages is called Web Developer.
Web Pages are created using HTML (HyperText Markup Language) syntax.
These pages must be organized and stored at a central computer (server
computer). The organization of web pages into directories and storing these files
on the server is called Website creation.
A website is a collection of static files (webpages) such as HTML pages,
images, graphics etc. A Web application is a web site with dynamic
functionality on the server. Dynamic functionality can be added using a high
level language which supports server side programming. Examples for server
side programming languages are Java, PHP, C#, Python etc. Google, Facebook,
Twitter are examples of web applications.
HyperText Markup Language (HTML)
The language used to develop web pages is called HyperText Markup Language
(HTML). HTML is the language interpreted by a Browser. Web Pages are also
called HTML documents. HTML is a set of special codes that can be embedded
in text to add formatting and linking information. HTML is specified as TAGS
in an HTML document.
Tags are instructions that are embedded directly into the text of the document.
An HTML tag is a signal to a browser that it should do something other than
just throw text up on the screen. By convention all HTML tags begin with an
open angle bracket (<) and end with a close angle bracket (>).
HTML tags can be of two types:
Paired tags: A tag is said to be a paired tag if it, along with a companion tag,
flanks the text. For example the <B> tag is a paired tag. The <B> tag with its
companion tag </B> causes the text contained between them to be rendered in
bold. The effect of other paired tags is applied only to the text they contain. In
paired tags, the first tag (<B>) is often called the opening tag and the second
tag (</B>) is called the closing tag. The opening tag activates the effect and the
closing tag turns the effect off.
Singular Tags: The second type of tag is the singular or stand-alone tag. A
stand-alone tag does not have a companion tag. For example <BR> tag will
insert a line break. This tag does not require any companion tag.
The Structure of an HTML program
Every HTML program has a rigid structure. The entire web page is enclosed
within <HTML> </HTML> tags. Within these tags two distinct sections are
created using the <HEAD> </HEAD> tags and the <BODY> </BODY> tags.
These sections are described below.
Document Head
Information placed in this section is essential to the inner workings of the
document and has nothing to do with the content of the document. With the
exception of information contained within the <TITLE></TITLE> tags, all
information placed within the <HEAD> </HEAD> tags is not displayed in the
browser. The HTML tags used to indicate the start and end of the head section
are:
<HEAD>
<TITLE>... </TITLE>
</HEAD>
Document Body
The tags used to indicate the start and end of the main body of textual
information are:
<BODY>... </BODY>
Page defaults like background color, text color, font size, font weight and so on
can be specified attributes of the <BODY> tag. The attributes that the <BODY>
tag takes are:
Attributes Description
alink Color of text for selected hyperlinks
background Image to be used a background
Text Styles
Making text Bold or Strong: We can make the text bold using the <B> tag.
The tag uses both opening and closing tag. The text that needs to be made bold
must be within <B> AND </B> tag.
We can also use the <STRONG> tag to make the text strong, with added
semantic importance. It also opens with <STRONG> and ends with
</STRONG> tag.
Making text Italic or emphasize: The <I> tag is used to italicise the text. It
opens with <I> and ends with </I> tag.
The <EM> tag is used to emphasize the text, with added semantic importance.
It opens with <EM> and ends with </EM> tag.
Links are created in a web page by using the <A>... </A> tags. Anything
written between the <A> </A> tags becomes a hyperlink/hotspot. By clicking
on the hyperlink navigation to a different web page or image takes place.
The document to be navigated needs to be specified. By using the HREF
attribute of the <A> tag the next navigable web page or image can be specified.
Syntax:
<A href="filename.html" >Hyperlink Text</a>
Hyperlinks can be of three types:
Links to an external document
Links to another webpage in outside website
Links (jumps) to a specific place within the same document .Generally
one in case of a web page containing a large amount of text
The anchor tag contains following attributes:
Attribute Value Description
href URL Specifies the URL of a page or the name of the
anchor that the link goes to.
target _blank Where to open the target URL.
_parent _blank - the target URL will open in a new
_self window.
_top _self - the target URL will open in the same frame
as it was clicked.
_parent - the target URL will open in the parent
frameset.
_top - the target URL will open in the full body of
the window.
name section name Marks an area of the page that a link jumps to.
LISTS
A list is a record of short pieces of information, such as people’s names, usually
written or printed with a single thing on each line and ordered in a way that
makes a particular thing easy to find.
For example:
A shopping list
To-do list
Lists in HTML
HTML offers three ways for specifying lists of information. All lists must
contain one or more list elements.
The types of lists that can be used in HTML are :
1. UL: An unordered list. This will list items using plain bullets.
2. OL: An ordered list. This will use different schemes of numbers to list
items.
3. DL: A definition list. This arranges items in the same way as they are
arranged in a dictionary.
The Unordered HTML List
An unordered list starts with the <UL> tag. Each list item starts with the <LI>
tag. The list items are marked with bullets i.e small black circles by default.
Example 5: Unordered List
<html>
<HEAD>
<TITLE>LIST</TITLE>
</HEAD>
<body>
<h2>Grocery list</h2>
<ul>
<li>Bread</li>
<li>Eggs</li>
<li>Milk</li>
<li>Coffee</li>
</ul>
</body>
</html>
Output
The TYPE Attribute can be used for <UL> tag to specify the type of bullet to be used. By
default, it is a disc. Following are the possible options −
<UL TYPE = "SQUARE">
<UL TYPE = "DISC">
<UL TYPE = "CIRCLE">
The Ordered HTML List
An unordered list starts with the <OL> tag. Each list item starts with the <LI>
tag. The list items are marked with numbers 1, 2…. by default.
The TYPE Attribute can be used for <OL> tag to specify the type of numbering to be used.
By default, it is a decimal numbers. Following are the possible options −
<OL TYPE = "A">
<OL TYPE = "a">
<OL TYPE = "I">
<OL TYPE = "i">
<OL TYPE = "1">
Type Description
type="1" The list items will be numbered with numbers (default)
type="A" The list items will be numbered with uppercase letters
type="a" The list items will be numbered with lowercase letters
type="I" The list items will be numbered with uppercase roman numbers
type="i" The list items will be numbered with lowercase roman numbers
Definition Lists
The definition list or description list, is different: it has neither bullets nor
numbers. The description list tag is <DL> and the list elements consist of a term
and its definition. The term is marked by <DT> tags and the definition by
<DD> tags.
Output
Creating Tables
A table is a grid organized into columns and rows, much like a spread sheet.
Tables were initially developed as a method to organize and display data in
columns and rows. Tables later became a tool for Web page layout, and as such
provide a possible solution for structured navigation.
Tables are useful for various tasks such as presenting text information and
numerical data. Tables can be used to compare two or more items in tabular
form layout. Tables are used to create databases.
Defining Tables in HTML
An HTML table is defined with the <TABLE> tag. Each table row is defined
with the <TR> tag. A table header is defined with the <TH> tag. By default,
table headings are bold and centered. A table data/cell is defined with the <TD>
tag.
Example 9: Tables
<html>
<HEAD>
<TITLE>LIST</TITLE>
</HEAD>
<body>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Priya</td>
<td>Sharma</td>
<td>24</td>
</tr>
<tr>
<td>Arun</td>
<td>Singh</td>
<td>32</td>
</tr>
<tr>
<td>Sam</td> <td>Watson</td> <td>41</td>
</tr>
</table>
</body>
</html>
Output
Frames
HTML Frames are used to divide the web browser window into multiple
sections where each section can be loaded separately. A FRAMESET tag is the
collection of frames in the browser window.
Creating Frames: Instead of using body tag, use <FRAMESET> tag in
HTML to use frames in web browser. The frameset tag is used to define how to
divide the browser. Each frame is indicated by <FRAME> tag and it basically
defines which HTML document shall open into the frame. The window is
divided into frames in a similar way the tables are organized: into rows and
columns. To define the horizontal frames use ROWS attribute of frame tag in
HTML document and to define the vertical frames use COLS attribute of frame
tag in HTML document.
There are few drawbacks with using frames .
Some smaller devices cannot cope with frames often because their screen
is not big enough to be divided up.
Sometimes webpage will be displayed differently on different computers
due to different screen resolution.
The browser's back button might not work as the user hopes.
There are still few browsers that do not support frame technology.
Syntax
<FRAMESET [COLS=”%,%”] [ROWS==”%,%”]>
<FRAME NAME=”NAME” SRC=”FILENAME” [FRAMEBORDER=”0”|”1”]
[SCROLLING=”YES”|AUTO|NO] >
</FRAMSET>
ROWS attribute will divide the webpage into horizontal frames and COLS
attribute divide page into vertical frames. The SRC attribute in <FRAME> point
to a valid HTML file or image which can be displayed within the frame.
Ex11.html
<html>
<head>
<title>Frame tag</title>
</head>
<frameset cols="25%,50%,25%">
<frame src="frame1.html" >
<frame src="frame2.html">
<frame src="frame3.html">
</frameset>
</html>
Output
The <form> tag in HTML is used to create form for user input. There are many
elements which are used within form tag. For example: <input>, <textarea>,
<button>, <select> and <option>
Syntax:
<FORM ACTION = "Script URL" METHOD = "GET|POST">
form elements like input, textarea etc.
</FORM>
Following is a list of the most frequently used form attributes
Attribute Description
action Backend script ready to process your passed data.
method Method to be used to upload data. The most frequently used are
GET and POST methods.
target Specify the target window or frame where the result of the script
will be displayed. It takes values like _blank, _self, _parent etc.
enctype You can use the enctype attribute to specify how the browser
encodes the data before it sends it to the server. Possible values are
−application/x-www-form-urlencoded − This is the standard
method most forms use in simple scenarios.
</body>
</html>
Output
2. Checkboxes Controls
The HTML <input type=”checkbox”> is used to define a checkbox field. The
checkbox is shown as a square box that is ticked when it is activated. It allows
the user to select one or more option among all the limited choices. They are
also created using HTML <input> tag but type attribute is set to a checkbox.
Attributes are
Attribute Description
type Indicates the type of input control and for checkbox input control
it will be set to a checkbox.
name Used to give a name to the control which is sent to the server to
be recognized and get the value.
value The value that will be used if the checkbox is selected
checked Set to checked if you want to select it by default
name Used to give a name to the control which is sent to the server to be
recognized and get the value.
selected Specifies that this option should be the initially selected value
when the page loads.
</form>
</body>
</html>
Output
name Used to give a name to the control which is sent to the server to
be recognized and get the value.
</html>
Output
6. Hidden Controls
Hidden form controls are used to hide data inside the page which later on can be
pushed to the server. This control hides inside the code and does not appear on
the actual page.
For example, following hidden form is being used to keep current page number.
When a user will click next page then the value of hidden control will be sent to
the web server and there it will decide which page will be displayed next based
on the passed current page.
Example 17:hidden field
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<p>This is page 10</p>
<input type = "hidden" name = "pagename" value = "10" />
<input type = "submit" name = "submit" value = "Submit" />
<input type = "reset" name = "reset" value = "Reset" />
</form>
</body>
</html>
Output
7. Clickable Buttons
There are various ways in HTML to create clickable buttons. A clickable button
can be created using <input>tag by setting its type attribute to button. The type
attribute can take the following values
Type Description
Submit This creates a button that automatically submits a form.