0% found this document useful (0 votes)
443 views185 pages

Complete Copy Black

PHP is a server-side scripting language used for web development. It allows creation of dynamic websites and has many features for interacting with various file formats and databases. Basic HTML page structure includes tags like <html>, <body>, <h1>, and <p> which are used to define headings and paragraphs. Common HTML tags and attributes are explained.

Uploaded by

abhijeetgoyal16
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
443 views185 pages

Complete Copy Black

PHP is a server-side scripting language used for web development. It allows creation of dynamic websites and has many features for interacting with various file formats and databases. Basic HTML page structure includes tags like <html>, <body>, <h1>, and <p> which are used to define headings and paragraphs. Common HTML tags and attributes are explained.

Uploaded by

abhijeetgoyal16
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 185

PHP PROGRAMMING !

PHP
PHP is server side scripting language for creating dynamic websites. It is Open source and easy to learn language widely used for website development. PHP was developed by Rasmus Lerdorf in 1994. PHP code is interpreted by server with a PHP Processor module which generates the web page. What is PHP: PHP is a well-known scripting language published by and for web developers: it is easy to understand, simple to set up and provides many of the programming resources a web designer could wish for all in one in free, cross-platform and open-source program. PHP allows you to develop extremely powerful, interactive and e-commerce web websites using server-side scripting methods just like or better than those offered by Windows ASP and Sun Microsystems JSP. PHP advantages: PHP applications run on the server so they prevent from the most of the incompatibility and servicing expenses associated with client-side (browser-based) approaches to interaction as Javascript. On the other side, PHP applications can be more effective and convenient than some other server-side approaches (including conventional CGI programs, as PHP applications developed for SQL Hosting server, MS Windows XP or Windows vista and the IIS server, can be implemented quickly and viably on robust enterprise class Linux and Unix system operating the Apache server and Oracle. In brief, PHP allows cross-platform, vendor-neutral alternatives, which can be developed and implemented on any well-known web structure

PHP features: PHP provides a number of resources for interacting with, shifting and transforming information saved in any number of ways as it can manage plain text, XML, HTML, XSLT, PDF, Postcript, SQL, ODBC, most RDBMs, encrypted authentication, secure sockets (SSL), SOAP and many other secure transaction techniques.

PAGE 1 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Web Servers and Clients


The focus of this class is on using PHP for web programming, it will be useful to briefly go over some very basic concepts about how the web works prior to diving into PHP itself. The web wasn't always so complex, of course. Back in the very early days, you could model the typical web transaction something like this:

A client (typically a web browser running on a desktop computer) sends a request for a particular file to a server. The request is formatted in a particular way that allows the server to identify where the file lives in its filesystem. The server returns the file, along with a brief header indicating the status of the request (successful, not successful) and a few other things that might help the client software process the response. Here's an example of the kind of request a browser might send out to a server. You may have seen something like this before ...

To be a bit more precise, this isn't a request, it is of course a URL, which is a way of representing an http request for inclusion in html documents. If the URL is hyperlinked, the browser translates the URL into an http request when the hyperlink is clicked.

PAGE 2 OF 185!

PHP PROGRAMMING !

You can see that the URL can be chunked into a number of definable parts. The first part specifies the protocol that is to be used to handle the request (the hypertext transfer protocol, or http, the fundamental protocol of the web); the second is the address of the server to which the request is being sent; the third is where the file lives on the server; and the fourth is the name of the file that the client wants to retrieve. An important thing to note here is that the file being sent back to the client (typically an html document, but possibly a binary file like an image) is a static entity. That works reasonably well for certain kinds of information (reports, essays, articles, pictures of cats) but falls down when it comes to other kinds of data. In this new example, the client is still sending a request for a file that lives in a particular location on the web server, but the file is no longer a simple static document. The client is now sending a request for a php script, which will presumably do something clever with the two parameters that now accompany the request. So we can now visualize the transaction as being more like this:

The web server still receives the request, but can no longer process the whole request by itself. Instead, it sees that the request is for a php script, so it passes off the processing of the script to the PHP interpreter, which is just another piece of software. The PHP interpreter processes the script (which in turn processes any parameters that have accompanied the request), and returns some output (generally html) to the web server, which in turn passes it back to the client. Websites are ONLINE APPS No need to install Just login and use Available from anywhere through Internet Operating system independent No piracy issues Spread info all over world
PAGE 3 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Website development has two Basic parts 1.Designing 2.Development In Designing part we use different tools and languages to make our site look good Designing Technologies: Designing Software: Development Software: Html,Css,Javascript Dreamweaver,Photoshop PHP, Mysql

PAGE 4 OF 185!

PHP PROGRAMMING !

HTML
HTML-HYPERTEXT MARKUP LANGUAGE HTML is a language for describing web pages.HTML stands for Hyper Text Markup Language.HTML is a markup language.HTML is case-insensitive language.A markup language is a set of markup tags.The tags describe document content.HTML documents contain HTML tags and plain text.HTML documents are also called web pages. HTML TAGS HTML tags are keywords (tag names) surrounded by angle brackets like <html> HTML tags normally come in pairs like <b> and </b> The first tag in a pair is the start tag, the second tag is the end tag The end tag is written like the start tag, with a forward slash before the tag name Start and end tags are also called opening tags and closing tags

<tagname>content</tagname>
BASIC WEB PAGE STRUCTURE <!DOCTYPE html> <html> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html> Example Explained The <!DOCTYPE> declaration is supported in all major browsers. The <!DOCTYPE> declaration must be the very first thing in your HTML document, before the <html> tag. The <!DOCTYPE> declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in. In HTML 4.01, the <!DOCTYPE> declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
PAGE 5 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Common DOCTYPE Declarations <!DOCTYPE html> HTML 4.01 Strict This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/ strict.dtd"> HTML 4.01 Transitional This DTD contains all HTML elements and attributes, INCLUDING presentational and deprecated elements (like font). Framesets are not allowed. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/ html4/loose.dtd"> HTML 4.01 Frameset This DTD is equal to HTML 4.01 Transitional, but allows the use of frameset content. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/ html4/frameset.dtd"> XHTML 1.0 Strict This DTD contains all HTML elements and attributes, but does NOT INCLUDE presentational or deprecated elements (like font). Framesets are not allowed. The markup must also be written as wellformed XML. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/ DTD/xhtml1-strict.dtd"> XHTML 1.0 Transitional The text between <html> and </html> describes the web page The text between <body> and </body> is the visible page content The text between <h1> and </h1> is displayed as a heading The text between <p> and </p> is displayed as a paragraph HTML can be edited in Tools like: Adobe Dreamweaver Microsoft Expression Web CoffeeCup HTML Editor However, for learning HTML we recommend a text editor like Notepad (PC) or TextEdit (Mac). We believe using a simple text editor is a good way to learn HTML.
PAGE 6 OF 185! !

PHP PROGRAMMING !

Writing HTML Using Notepad or TextEdit


Follow the 4 steps below to create your first web page with Notepad.

Step 1: Start Notepad To start Notepad go to: Start -> All Programs ->Accessories ->Notepad Step 2: Edit Your HTML with Notepad Type your HTML code into your Notepad: Step 3: Save Your HTML Select Save as.. in Notepad's file menu. When you save an HTML file, you can use either the .htm or the .html file extension. There is no difference, it is entirely up to you. Save the file in a folder that is easy to remember, like Netmax.

Step 4: Run the HTML in Your Browser Start your web browser and open your html file from the File, Open menu, or just browse the folder and double-click your HTML file. The result should look much like this:

PAGE 7 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

HTML Attributes HTML elements may have attributes Attributes provide additional information about an element Attributes are always specified in the start tag Attributes come in name/value pairs like: name="value" Attribute Example
HTML links are defined with the <a> tag. The link address is specified in the href attribute:

<a href="http://www.netmaxtech.com">This is a link</a>

HTML COMMON TAG LIST Example of Text tags


<html> <head> <title>Text Tags</title> </head> <body bgcolor="pink" background='images/image1.jpg'> <!-- Text elements and their attributes--> <p>This is an Example of a paragraph</p> <h1>Netmax Technologies</h1> <h2>Netmax Technologies</h2> <h3>Netmax Technologies</h3> <h4>Netmax Technologies</h4> <h5>Netmax Technologies</h5> <h6 align='right'>Netmax Technologies</h6> <!--Moving text--> <marquee direction='down' onmouseover="this.stop()" onmouseout="this.start()" scrollamount="30">Netmax Technologies</marquee> </body> </html>

Example of Image, links,character formatting tags


<html>
PAGE 8 OF 185! !

PHP PROGRAMMING !

<head> <title>Html Tags</title> </head> <body> <!--Character Formatting Tags--> <p><font color="red" size="3" face="arial">Netmax</font></p> <p><i>Welcome</i> <u><b>user</b></u> to our site</p> <!--Embedding Images--> <img src='images/cisco_logo.png' alt='cisco logo' title='cisco'/> <!--Empty tags--> <br><hr> <!--Creating links--> <a href='#'>Link</a> <a href='http://yahoo.com'>Yahoo</a> <a href='home.html'>Home</a> </body> </html>

Example of lists(Ordered list,Unordered List,Defination List)


<html> <head> <title>Lists</title> </head> <body> <!--Unordered List--> <ul type="square"> <li>Home</li> <li>Contact us</li> <li>About us</li> </ul> <!--Ordered List--> <ol type="I" start="3"> <li>Home</li> <li>Contact us</li> <li>About us</li>
PAGE 9 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

</ol> <!--Defination List--> <dl> <dt>PHP</dt> <dd>php is scripting language to bulid sites</dd> <dt>AsP.net</dt> <dd>in asp.net we can create websites</dd> </dl> </body> </html>

Example of creating forms


<html> <head> <title>Form elements</title> </head> <body> <fieldset> <legend>Application form</legend> <form action="a.html" method="post"> Username<input type="text" name="user" value="enter name" size="40"/> <label>Password</label><input type="password" name="pass" value="123" readonly="true"/> <label>Gender</label> <input type="radio" name="gen" value="m">Male</input> <input type="radio" name="gen" value="f">Female</input> <label>Hobbies</label> <input type="checkbox">Music</input> <input type="checkbox">Arts</input><br> Message <textarea rows="10" cols="40">enter msg here</textarea> Countries<select name="cn" multiple="multiple"> <option value='ind'>India</option> <option value='usa'>USA</option> <option value='aus'>Australia</option> </select> <input type="submit" value="create account"/> <input type="button" value="go to next"/> <input type="reset"/>
PAGE 10 OF 185! !

PHP PROGRAMMING !

<button>Click</button> </form> </fieldset> </body></html>

Example of tables
<html> <head> <title>Creating Tables</title> </head> <body> <table border="1"> <tr> <th>Header 1</th> <th>Header 2</th> </tr> <tr> <td>row 1, cell 1</td> <td>row 1, cell 2</td> </tr> <tr> <td>row 2, cell 1</td> <td>row 2, cell 2</td> </tr> </table> </body> </html>

Example of table with Nested Tables with Rowspan and colspan <html>
<body> <table border="2" width="100%" height="100%" cellpadding="13px" cellspacing="10px" bordercolor="green"> <tr> <th colspan="2">Students Information</th> </tr> <tr> <td rowspan="2">name</td> <td> <table border="1" width="100%" height="100%"> <tr bgcolor="red"><td>first</td><td>second</td></tr> </table> </td> </tr> <tr> <td>Aman</td> </tr> </table> </body> </html>
PAGE 11 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

CSS:Cascading Style Sheets


What is CSS?
CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles are normally stored in Style Sheets Styles were added to HTML 4.0 Style Sheets can save you a lot of work CSS contain properties applied on different tags

CSS Syntax

A CSS rule has two main parts: a selector, and one or more declarations: The selector is normally the HTML element you want to style. Each declaration consists of a property and a value. The property is the style attribute you want to change. Each property has a value. For each selector there are 'properties' inside curly brackets, which simply take the form of words such as color, font-weight or background-color. A value is given to the property following a colon (NOT an 'equals' sign) and semi-colons separate the properties.

Types of Stylesheets
1.Inline Stylesheetapplied on one tag at a time 2.Internal Stylesheet---applied on one page 3.External Stylesheet---applied on multiple webpages

In-line
PAGE 12 OF 185! !

PHP PROGRAMMING !

In-line styles are used straight into the HTML tags using the style attribute.They look something like this:
Syntax: <p style=color:red>Text</p> This will make that specific paragraph red. The approach of HTML Document is that the HTML should be a stand-alone,presentation free document, and so in-line styles should be avoided wherever possible.

Internal
Internal styles are used for the whole page. Inside the head tags, the style tag surrounds all of the styles for the page. This would look something like this: Syntax: <html> <head> <title>CSS Example</title> <style type="text/css"> p {color: red;} </style> </head> <body> <p>hello world!</p> </html> This will make all of the paragraphs in the page red and all of the links blue.

External
External styles are used for the whole, multiple-page website. There is a separate CSS file, which will simply look something like:

Syntax:
p { a { color:red; color: blue; } }

If this file is saved as 'web.css' then it can be linked to in the HTML like this: Syntax:
PAGE 13 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<html> <head> <title>CSS Example</title> <link rel="stylesheet" type="text/css" href="web.css" /> </head> <body> <p>This is demo </p> <a href='#'>Home</a> </body> </html>

Grouping
You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. All header elements will be displayed in green text color: Syntax h1,h2,h3,h4,h5,h6 { color: green }

Id and class Attribute's/Selectors


In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class". The id Selector The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". The style rule below will be applied to the element with id="para1": Example: #para1 { text-align:center; color:red; } Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.

The class Selector


The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements. This allows you to set a particular style for many HTML elements with the same class. The class selector uses the HTML class attribute, and is defined with a "." In the example below, all HTML elements with class="center" will be center-aligned:
PAGE 14 OF 185! !

PHP PROGRAMMING !

Example: .center {text-align:center;} p.center {text-align:center;} You can also specify that only specific HTML elements should be affected by a class. Example: p.center {text-align:center;} Do NOT start a class name with a number! This is only supported in Internet Explorer.

Example of id and class selectors


<html> <head> <title>Id and Class</title> <style type="text/css"> #para1 { color:red; font-size:22; } .second { color:blue; font-size:44; } </style> </head> <body> <p id="para1">This is text</p> <h2>This is an example of css</h2> <p class="second">This is text</p> <h2 class="second">This is an example of css</h2> <p>This is text</p> <h2>This is an example of css</h2> </body> </html>

CSS Comments
Comments are used to explain your code, and may help you when you edit the source code at a later date. A comment will be ignored by browsers. A CSS comment begins with "/*", and ends with "*/", like this:
PAGE 15 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

/* This is a comment */ p { text-align: center; /* This is another comment */ color: black; font-family: arial }

CSS Background Properties


The CSS background properties allow you to control the background color of an element, set an image as the background, repeat a background image vertically or horizontally, and position an image on a page. Property background Values background-color background-image background-repeat backgroundattachment background-position backgroundSets whether a background image is fixed or scroll attachment scrolls with the rest of the page fixed background-color Sets the background color of an element color-rgb color-hex color-name transparent background-image Sets an image as the background url none background-position Sets the starting position of a background top left image top center top right center left center center center right bottom left bottom center bottom right x-% y-% x-pos y-pos background-repeat Sets if/how a background image will be repeat repeated repeat-x repeat-y no-repeat
PAGE 16 OF 185! !

Description A shorthand property for setting all background properties in one declaration

PHP PROGRAMMING !

Example:
<html> <head> <style type="text/css"> body { background:#ffffff ; background-image:url('img_tree.png') background-repeat:no-repeat; background-position: right top; background-attachment:fixed; } </style> </head> <body> <h1>Hello World!</h1> <p>Now the background image is only shown once, and it is also positioned away from the text.</p> </body> </html>

CSS Text Properties


The CSS text properties allow you to control the appearance of text. It is possible to change the color of a text, increase or decrease the space between characters in a text, align a text, decorate a text, indent the first line in a text, and more. Property color direction letter-spacing text-align Description Sets the color of a text Sets the text direction Increase or decrease the space between characters Aligns the text in an element Values color ltr rtl normal length left right center justify

PAGE 17 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

text-decoration

Adds decoration to text

text-indent text-transform

white-space

word-spacing

none underline overline line-through blink Indents the first line of text in an element length % Controls the letters in an element none capitalize uppercase lowercase Sets how white space inside an element is normal handled pre nowrap Increase or decrease the space between words normal length

CSS Font Properties


The CSS font properties allow you to change the font family, boldness, size, and the style of a text. Note: In CSS1 fonts are identified by a font name. If a browser does not support the specified font, it will use a default font. Browser support: IE: Internet Explorer, F: Firefox, N: Netscape. W3C: The number in the "W3C" column indicates in which CSS recommendation the property is defined (CSS1 or CSS2). Property font Description A shorthand property for setting all of the properties for a font in one declaration Values font-style font-variant font-weight font-size/line-height font-family caption icon menu message-box small-caption status-bar A prioritized list of font family names and/or family-name generic family names for an element generic-family

font-family

PAGE 18 OF 185!

PHP PROGRAMMING !

font-size

Sets the size of a font

font-stretch

Condenses or expands the current fontfamily

font-style

Sets the style of the font

font-variant font-weight

Displays text in a small-caps font or a normal font Sets the weight of a font

xx-small x-small small medium large x-large xx-large smaller larger length % normal wider narrower ultra-condensed extra-condensed condensed semi-condensed semi-expanded expanded extra-expanded ultra-expanded normal italic oblique normal small-caps normal bold bolder lighter 100 200 300 400 500 600 700 800 900

PAGE 19 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Example of font and text Properties


<html> <head> <style type="text/css"> p { font-size:22; color:red; font-style:italic; font-weight:bold; font-family:arial; text-align:center; text-decoration:underline; text-transfor:uppercase; } </style> </head> <body> <p> This Paragraph is changed using css properties </p> </body> </html>

CSS List properties


In HTML, there are two types of lists: unordered lists - the list items are marked with bullets ordered lists - the list items are marked with numbers or letters The CSS list properties allow you to place the list-item marker, change between different list-item markers, or set an image as the list-item marker. Property list-style Description A shorthand property for setting all of the properties for a list in one declaration Sets an image as the list-item marker Values list-style-type list-style-position list-style-image none url

list-style-image

PAGE 20 OF 185!

PHP PROGRAMMING !

list-style-position list-style-type

Sets where the list-item marker is placed in inside the list outside Sets the type of the list-item marker none disc circle square decimal decimal-leading-zero lower-roman upper-roman lower-alpha upper-alpha lower-greek lower-latin upper-latin hebrew armenian

Example of list List properties


<html> <head> <style type="text/css"> ol li { list-style-type:upper-alpha; list-style-position:inside; } </style> </head> <body> <ul> <li>Home</li> <li>Contact Us </li> <li>About</li> </ul> </body> </html>

All list properties in one declaration


PAGE 21 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<html> <head> <style type="text/css"> ul { list-style: square inside url('arrow.gif') } </style> </head> <body> <ul> <li>Home</li> <li>Contact Us </li> <li>About</li> </ul> </body> </html>

CSS Pseudo-classes
CSS pseudo-classes are used to add special effects to some selectors Syntax

selector:pseudo-class {property: value}


CSS classes can also be used with pseudo-classes:

selector.class:pseudo-class {property: value} Anchor Pseudo-classes


A link that is active, visited, unvisited, or when you mouse over a link can all be displayed in different ways in a CSS-supporting browser: a:link {color: #FF0000} /* unvisited link */ a:visited {color: #00FF00} /* visited link */ a:hover {color: #FF00FF} /* mouse over link */ a:active {color: #0000FF} /* selected link */ Note: a:hover MUST come after a:link and a:visited in the CSS definition in order to be effective!! Note: a:active MUST come after a:hover in the CSS definition in order to be effective!! Note: Pseudo-class names are not case-sensitive.
PAGE 22 OF 185! !

PHP PROGRAMMING !

Pseudo-classes and CSS Classes


Pseudo-classes can be combined with CSS classes: a.red:visited {color: #FF0000} <a class="red" href="css_syntax.asp">CSS Syntax</a> If the link in the example above has been visited, it will be displayed in red.

Example of link Properties


<!--Link properties in css--> <html> <head> <style type="text/css"> a#top:link { color:red; font-size:22; text-decoration:none; } a#top:visited { color:green; font-size:22; text-decoration:none; } a#top:hover { color:blue; font-size:22; text-decoration:none; } a#top:active { color:pink; font-size:22; text-decoration:none; } </style> </head> <body> <h1>Netmax Technologies</h1> <ul> <li>Home</li> <li>Contact us </li>
PAGE 23 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<li>About us</li> </ul> <a href="#" id="top">Java</a> <a href="#" id="top">PHP</a> <p>copyright</p> <h1>Footer area</h1> <a href='#'>CCNA</a> <a href='#'>CCIE</a> </body> </html>

CSS Display Properties


Block and Inline Elements A block element is an element that takes up the full width available, and has a line break before and after it. Examples of block elements:
<h1> <p> <div>

An inline element only takes up as much width as necessary, and does not force line breaks. Examples of inline elements:

<span> <a> Changing How an Element is Displayed


Changing an inline element to a block element, or vice versa, can be useful for making the page look a specific way, and still follow web standards. The following example displays list items as inline elements: <!DOCTYPE html> <html> <head> <style> li{ display:inline; }
PAGE 24 OF 185! !

PHP PROGRAMMING !

a { display:block; } </style> </head> <body> <p>Display this link list as a horizontal menu:</p> <ul> <li></li> <li>CSS</a></li> <li>JavaScript</li> <li>XML</li> </ul> <a href="css.html" target="_blank">CSS</a> <a href="java.html" target="_blank">Java</a> </body> </html>

Hiding an Element - display:none or visibility:hidden


Hiding an element can be done by setting the display property to "none" or the visibility property to "hidden". However, notice that these two methods produce different results: <html> <head> <style> #test1{ display:none; } a#one: { visibility:hidden; } </style>
PAGE 25 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

</head> <body> <p>Display this link list as a horizontal menu:</p> <ul> <li></li> <li>CSS</a></li> <li id=test1>JavaScript</li> <li>XML</li> </ul> <a href="css.html" target="_blank" id=one>CSS</a> <a href="java.html" target="_blank">Java</a> </body> </html>

CSS Border Properties


The CSS border properties allow you to specify the style and color of an element's border. In HTML we use tables to create borders around a text, but with the CSS border properties we can create borders with nice effects, and it can be applied to any element. Property border Description Values A shorthand property for setting all of the border-width properties for the four borders in one declaration border-style border-color A shorthand property for setting all of the border-bottomproperties for the bottom border in one width declaration border-style border-color Sets the color of the bottom border border-color Sets the style of the bottom border Sets the width of the bottom border border-style

border-bottom

border-bottomcolor border-bottomstyle border-bottomwidth

border-color

thin medium thick length Sets the color of the four borders, can have from color one to four colors

PAGE 26 OF 185!

PHP PROGRAMMING !

border-left

border-left-color border-left-style

A shorthand property for setting all of the border-left-width properties for the left border in one declaration border-style border-color Sets the color of the left border border-color Sets the style of the left border border-style

border-left-width Sets the width of the left border

thin medium thick length border-right A shorthand property for setting all of the border-right-width properties for the right border in one declaration border-style border-color border-right-color Sets the color of the right border border-color border-right-style Sets the style of the right border border-right-width Sets the width of the right border border-style thin medium thick length Sets the style of the four borders, can have from none one to four styles hidden dotted dashed solid double groove ridge inset outset A shorthand property for setting all of the border-top-width properties for the top border in one declaration border-style border-color Sets the color of the top border border-color Sets the style of the top border border-style thin medium thick length A shorthand property for setting the width of the thin four borders in one declaration, can have from medium one to four values thick length

border-style

border-top

border-top-color border-top-style

border-top-width Sets the width of the top border

border-width

PAGE 27 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Example of Border properties


<html> <head> <style type="text/css"> table { width:100%; height:100%; border-left-style:dashed; border-left-color:red; border-left-width:3px; border:2px solid red; border-left:3px dashed green; border-collapse:collapse; } tr,td { border:2px dotted blue; } </style> </head> <body> <table> <tr> <td>Cell1</td> <td>Cell2</td> </tr> <tr> <td>cell3</td> <td>cell4</td> </tr> </table> </body> </html>

CSS Margin Properties


The CSS margin properties define the space around elements. It is possible to use negative values to overlap content. The top, right, bottom, and left margin can be changed independently using separate properties. A shorthand margin property can also be used to change all of the margins at once.

PAGE 28 OF 185!

PHP PROGRAMMING !

Property margin

Description A shorthand property for setting the margin properties in one declaration

margin-bottom

Sets the bottom margin of an element

margin-left

Sets the left margin of an element

margin-right

Sets the right margin of an element

margin-top

Sets the top margin of an element

Values margin-top margin-right margin-bottom margin-left auto length % auto length % auto length % auto length %

CSS Padding Properties The CSS padding properties define the space between the element border and the element content. Negative values are not allowed. The top, right, bottom, and left padding can be changed independently using separate properties. A shorthand padding property is also created to control multiple sides at once.
Property padding Description Values A shorthand property for padding-top setting all of the padding padding-right properties in one padding-bottom declaration padding-left Sets the bottom padding of length an element % Sets the left padding of an length element % Sets the right padding of length an element % Sets the top padding of an length element %

padding-bottom padding-left padding-right padding-top

CSS Classification Properties The CSS classification properties allow you to control how to display an element, set where an image will appear in another element, position an element relative to its normal position, position an element using an absolute value, and how to control the
PAGE 29 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

visibility of an element.
Property Description Values

Clear

Sets the sides of an element where other floating elements are not allowed

cursor

Specifies the type of cursor to be displayed

Float

Sets where an image or a text will appear in another element

left right both none url auto crosshair default pointer move e-resize ne-resize nw-resize n-resize se-resize sw-resize s-resize w-resize text wait help left right none

Example of margin,padding and float


<html> <head> <style type="text/css"> #header { width:100%;height:800px; background-color:red; }

#left { width:300px; height:150px; background-color:yellow;


PAGE 30 OF 185! !

PHP PROGRAMMING !

margin-left:10px; float:left; } #right { width:300px; height:150px; background-color:blue; float:left; margin-left:30px; } </style> </head> <body> <div id="header"> <div id="left"> </div> <div id="right"> </div> </div> </body> </html>

CSS Positioning Properties The CSS positioning properties allow you to specify the left, right, top, and bottom position of an element. It also allows you to set the shape of an element, place an element behind another, and to specify what should happen when an element's content is too big to fit in a specified area.
Property bottom Description Values Sets how far the bottom edge of an element is auto above/below the bottom edge of the parent element % length Sets how far the left edge of an element is to the auto right/left of the left edge of the parent element % length Sets what happens if the content of an element visible overflow its area hidden scroll auto
! NETMAX TECHNOLOGIES

Left

overflow

PAGE 31 OF 185!

SUBJECT: HTML BASICS!

position

Places an element in a static, relative, absolute or fixed position

right

Sets how far the right edge of an element is to the left/right of the right edge of the parent element Sets how far the top edge of an element is above/ below the top edge of the parent element Sets the vertical alignment of an element

top

vertical-align

z-index

Sets the stack order of an element

static relative absolute fixed auto % length auto % length baseline sub super top text-top middle bottom text-bottom length % auto number

static absolute fixed relative inherit

Default. Elements render in order, as they appear in the document flow The element is positioned relative to its first positioned (not static) ancestor element The element is positioned relative to the browser window The element is positioned relative to its normal position, so "left:20" adds 20 pixels to the element's LEFT position The value of the position property is inherited from the parent element

Example of Relative Position


<html> <head> <title>Css positioning</title> <style type="text/css"> #header {
PAGE 32 OF 185! !

PHP PROGRAMMING !

width:200px; height:200px; background-color:red; } #main { width:200px; height:200px; background-color:yellow; position:relative; top:0px;left:50px; } #left { width:100px; height:100px; background-color:green; position:absolute; left:30px;top:20px; } </style> <body> <div id="header"> </div> <div id="main"> <div id="left"> </div> <div id="right"> </div> </div> </body> </html>

Example of Absolute Position


<html> <head> <title>Css positioning</title> <style type="text/css"> #header
PAGE 33 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

{ width:200px; height:200px; background-color:red; } #main { width:200px; height:200px; background-color:yellow; position:absolute; top:0px;left:50px; } #left { width:100px; height:100px; background-color:green; position:absolute; left:30px;top:20px; } </style> <body> <div id="header"> </div> <div id="main"> <div id="left"> </div> <div id="right"> </div> </div> </body> </html>

Example of Fixed Position and Relative Position together


<html> <head> <title>Css positioning</title> <style type="text/css"> #header { width:200px;
PAGE 34 OF 185! !

PHP PROGRAMMING !

height:200px; background-color:red; } #main { width:200px; height:200px; background-color:yellow; position:relative; } #left { width:100px; height:100px; background-color:green; position:fixed; left:30px;top:20px; } </style> <body> <div id="header"> </div> <div id="main"> <div id="left"> </div> <div id="right"> </div> </div> </body> </html>

Example of Absolute Position and Relative Position together


<html> <head> <title>Css positioning</title> <style type="text/css"> #header { width:200px; height:200px; background-color:red; }
PAGE 35 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

#main { width:200px; height:200px; background-color:yellow; position:relative; } #left { width:100px; height:100px; background-color:green; position:absolute; left:30px;top:20px; } </style> <body> <div id="header"> </div> <div id="main"> <div id="left"> </div> <div id="right"> </div> </div> </body> </html>

PAGE 36 OF 185!

PHP PROGRAMMING !

JAVASCRIPT
By definition, JavaScript is a client-side scripting language. This means the web surfer's browser will be running the script. The opposite of client-side is server-side, which occurs in a language like PHP. PHP scripts are run by the web hosting server. JavaScript is the most popular scripting language on the internet, and works in all major browsers, such as Internet Explorer, Mozilla, Firefox, Netscape, Opera.

Introduction to JavaScript
JavaScript is a scripting language - a scripting language is a lightweight programming language JavaScript was designed to add interactivity to HTML pages A JavaScript is lines of executable computer code A JavaScript is usually embedded directly in HTML pages JavaScript is an interpreted language (means that scripts execute without preliminary compilation) Everyone can use JavaScript without purchasing a license JavaScript is case sensitive Language. Javascript can be used to create

Sliders Drop down menus Form Validations 2. How to Put a JavaScript Into an HTML Page
<html> <body> <script type="text/javascript"> document.write("Hello World!") </script> </body> </html> Hello World! Ending Statements With a Semicolon? Tell the browser where script code ends

Tell the browser where script code begins

The code above will produce this output on an HTML page:

PAGE 37 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

With traditional programming languages, like C++ and Java, each code statement has to end with a semicolon. Many programmers continue this habit when writing JavaScript, but in general, semicolons are optional! However, semicolons are required if you want to put more than one statement on a single line. How to Handle Older Browsers Browsers that do not support JavaScript will display the script as page content. To prevent them from doing this, we may use the HTML comment tag: <script type="text/javascript"> <!-document.write("Hello World!") //--> </script> The two forward slashes at the end of comment line (//) are a JavaScript comment symbol. This prevents the JavaScript compiler from compiling the line. Where to Put the JavaScript? Scripts in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, other times when a user triggers an event. Scripts in the head section: Scripts to be executed when they are called, or when an event is triggered, go in the head section. When you place a script in the head section, you will ensure that the script is loaded before anyone uses it.

<html>
<head> <script type="text/javascript"> some statements </script> </head> Scripts in the body section: Scripts to be executed when the page loads go in the body section. When you place a script in the body section it generates the content of the page. <html> <head> </head> <body>
PAGE 38 OF 185! !

PHP PROGRAMMING !

<script type="text/javascript"> some statements </script> </body> Scripts in both the body and the head section: You can place an unlimited number of scripts in your document, so you can have scripts in both the body and the head section. <html> <head> <script type="text/javascript"> some statements </script> </head> <body> <script type="text/javascript"> some statements </script> </body>

Define Variables
A variable is a "container" for information you want to store. A variable's value can change during the script. You can refer to a variable by name to see its value or to change its value. Rules for Variable names: Variable names are case sensitive They must begin with a letter or the underscore character How to declare a Variable? You can create a variable with the var statement: var strname = some value You can also create a variable without the var statement: strname = some value How to Assign a Value to a Variable? You assign a value to a variable like this: var strname = "Net" Or like this:
PAGE 39 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

strname = "NET" The variable name is on the left side of the expression and the value you want to assign to the variable is on the right. So far, youve seen examples of variable values that are strings. In JavaScript, the variable values, or types, can include number, string, Boolean, and null. Unlike stricter programming languages, JavaScript does not force you to declare the type of variable when you define it. Instead, JavaScript allows virtually any value to be assigned to any variable.

JAVASCRIPT OPERATORS Arithmetic Operators


Operator + * / % Description Addition Subtraction Multiplication Division Modulus (division remainder) Increment Decrement Example x=2 x+2 x=2 5-x x=4 x*5 15/5 5/2 5%2 10%8 10%2 x=5 x++ x=5 x-Result 4 3 20 3 2.5 1 2 0 x=6 X=4

++ --

Assignment operators
Operator = += -= *= /= %= Example x=y x+=y x-=y x*=y x/=y x%=y Is The Same As x=y x=x+y x=x-y x=x*y x=x/y x=x%y

Comparison Operators
Operator ==
PAGE 40 OF 185!

Description is equal to
!

Example 5==8 returns false

PHP PROGRAMMING !

!= > < >= <=

is not equal is greater than is less than is greater than or equal to is less than or equal to

5!=8 returns true 5>8 returns false 5<8 returns true 5>=8 returns false 5<=8 returns true

Logical Operators in javascript.


Operator && Description and Example x=6 y=3 (x < 10 && y > 1) returns true x=6 y=3 (x==5 || y==5) returns false x=6 y=3 !(x==y) returns true

||

or

not

Conditional Operator
JavaScript also contains a conditional operator that assigns a value to a variable based on some condition. Syntax variablename=(condition)?value1:value2 Example greeting=(visitor=="PRES")?"Dear President ":"Dear " If the variable visitor is equal to PRES, then put the string "Dear President " in the variable named greeting. If the variable visitor is not equal to PRES, then put the string "Dear " into the variable named greeting.

String Operator in Javascript.


A string is most often text, for example "Hello World!". To stick two or more string variables together, use the + operator. txt1="What a very"
PAGE 41 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

txt2="nice day!" txt3=txt1+txt2 The variable txt3 now contains "What a verynice day!". To add a space between two string variables, insert a space into the expression, OR in one of the strings. txt1="What a very" txt2="nice day!" txt3=txt1+" "+txt2 or txt1="What a very " txt2="nice day!" txt3=txt1+txt2 The variable txt3 now contains "What a very nice day!".

Types of Javascript's
1.Internal JavaScript----works on one page 2.External Javascript-----can be used on multiple pages

Using an External JavaScript


Sometimes you might want to run the same JavaScript on several pages, without having to write the same script on every page. To simplify this, you can write a JavaScript in an external file. Save the external JavaScript file with a .js file extension. Note: The external script cannot contain the <script> tag! To use the external script, point to the .js file in the "src" attribute of the <script> tag: <html> <head> <script type=text/javascript src="xxx.js"></script> </head> <body> </body> </html>

Note: Remember to place the script exactly where you normally would write the script! JavaScript Date Today (Current)
PAGE 42 OF 185! !

PHP PROGRAMMING !

To warm up our JavaScript Date object skills, let's do something easy. If you do not supply any arguments to the Date constructor (this makes the Date object) then it will create a Date object based on the visitor's internal clock.

HTML & JavaScript Code:


<h4>It is now <script type="text/javascript"> <!-var currentTime = new Date() //--> </script> </h4>

Display: It is now
Nothing shows up! That's because we still don't know the methods of the Date object that let us get the information we need (i.e. Day, Month, Hour, etc).

Get the JavaScript Time


The Date object has been created, and now we have a variable that holds the current date! To get the information we need to print out, we have to utilize some or all of the following functions: getTime() - Number of milliseconds since 1/1/1970 @ 12:00 AM getSeconds() - Number of seconds (0-59) getMinutes() - Number of minutes (0-59) getHours() - Number of hours (0-23) getDay() - Day of the week(0-6). 0 = Sunday, ... , 6 = Saturday getDate() - Day of the month (0-31) getMonth()- Number of month (0-11) getFullYear() - The four digit year (1970-9999) Now we can print out the date information. We will be using the getDate, getMonth, and getFullYear methods in this example.

HTML & JavaScript Code:


<h4>It is now <script type="text/javascript"> <!-var currentTime = new Date() var month = currentTime.getMonth() + 1 var day = currentTime.getDate() var year = currentTime.getFullYear()
PAGE 43 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

document.write(month + "/" + day + "/" + year) //--> </script> </h4>

Display: It is now 1/5/2012 !


Notice that we added 1 to the month variable to correct the problem with January being 0 and December being 11. After adding 1, January will be 1, and December will be 12.

Conditional Statements
Conditional statements in JavaScript are used to perform different actions based on different conditions.

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 JavaScript we have the following conditional statements: if statement - use this statement if you want to execute some code only if a specified condition is true if...else statement - use this statement if you want to execute some code if the condition is true and another code if the condition is false if...else if....else statement - use this statement if you want to select one of many blocks of code to be executed switch statement - use this statement if you want to select one of many blocks of code to be executed

If Statement
You should use the if statement if you want to execute some code only if a specified condition is true.

Syntax
if (condition) { code to be executed if condition is true } Note that if is written in lowercase letters. Using uppercase letters (IF) will generate a JavaScript error!

Example 1

PAGE 44 OF 185!

PHP PROGRAMMING !

<script type="text/javascript"> //Write a "Good morning" greeting if //the time is less than 10 var d=new Date() var time=d.getHours() if (time<10) { document.write("<b>Good morning</b>") } </script>

Example 2
<script type="text/javascript"> //Write "Lunch-time!" if the time is 11 var d=new Date() var time=d.getHours() if (time==11) { document.write("<b>Lunch-time!</b>") } </script> Note: When comparing variables you must always use two equals signs next to each other (==)! Notice that there is no ..else.. in this syntax. You just tell the code to execute some code only if the specified condition is true.

If...else Statement
If you want to execute some code if a condition is true and another code if the condition is not true, use the if....else statement.

Syntax
if (condition) { code to be executed if condition is true } else { code to be executed if condition is not true }
PAGE 45 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Example
<script type="text/javascript"> //If the time is less than 10, //you will get a "Good morning" greeting. //Otherwise you will get a "Good day" greeting. var d = new Date() var time = d.getHours() if (time < 10) { document.write("Good morning!") } else { document.write("Good day!") } </script>

If...else if...else Statement


You should use the if....else if...else statement if you want to select one of many sets of lines to execute.

Syntax
if (condition1) { code to be executed if condition1 is true } else if (condition2) { code to be executed if condition2 is true } else { code to be executed if condition1 and condition2 are not true }

Example
PAGE 46 OF 185! !

PHP PROGRAMMING !

<script type="text/javascript"> var d = new Date() var time = d.getHours() if (time<10) { document.write("<b>Good morning</b>") } else if (time>10 && time<16) { document.write("<b>Good day</b>") } else { document.write("<b>Hello World!</b>") } </script>

Conditional statements in JavaScript are used to perform different actions based on different conditions.

The JavaScript Switch Statement


You should use the switch statement if you want to select one of many blocks of code to be executed.

Syntax
switch(n) { case 1: execute code block 1 break case 2: execute code block 2 break default: code to be executed if n is different from case 1 and 2 } This is how it works: First we have a single expression n (most often a variable), that is evaluated once. The value of the expression is then compared with the values for each case in the structure. If there is a match, the block of code associated with that case is executed. Use break to prevent the code from running into the next case automatically.

Example
PAGE 47 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<script type="text/javascript"> //You will receive a different greeting based //on what day it is. Note that Sunday=0, //Monday=1, Tuesday=2, etc. var d=new Date() theDay=d.getDay() switch (theDay) { case 5: document.write("Finally Friday") break case 6: document.write("Super Saturday") break case 0: document.write("Sleepy Sunday") break default: document.write("I'm looking forward to this weekend!") } </script>

JavaScript For Loop Loops in JavaScript are used to execute the same block of code a specified number of times or while a specified condition is true. JavaScript Loops
Very often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use loops to perform a task like this. In JavaScript there are two different kind of loops: for - loops through a block of code a specified number of times while - loops through a block of code while a specified condition is true The for Loop The for loop is used when you know in advance how many times the script should run. Syntax for (var=startvalue;var<=endvalue;var=var+increment) { code to be executed }
PAGE 48 OF 185! !

PHP PROGRAMMING !

Example Explanation: The example below defines a loop that starts with i=0. The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs. Note: The increment parameter could also be negative, and the <= could be any comparing statement. <html> <body> <script type="text/javascript"> var i=0 for (i=0;i<=10;i++) { document.write("The number is " + i) document.write("<br />") } </script> </body> </html>

Result
The number is 0 The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 The number is 6 The number is 7 The number is 8 The number is 9 The number is 10

JavaScript While Loop


Loops in JavaScript are used to execute the same block of code a specified number of times or while a specified condition is true.

The while loop


The while loop is used when you want the loop to execute and continue executing while the specified condition is true. while (var<=endvalue) { code to be executed }

Note: The <= could be any comparing statement.


PAGE 49 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Example
Explanation: The example below defines a loop that starts with i=0. The loop will continue to run as long as i is less than, or equal to 10. i will increase by 1 each time the loop runs. <html> <body> <script type="text/javascript"> var i=0 while (i<=10) { document.write("The number is " + i) document.write("<br />") i=i+1 } </script> </body> </html>

Result
The number is 0 The number is 1 The number is 2 The number is 3 The number is 4 The number is 5 The number is 6 The number is 7 The number is 8 The number is 9 The number is 10

The do...while Loop


The do...while loop is a variant of the while loop. This loop will always execute a block of code ONCE, and then it will repeat the loop as long as the specified condition is true. This loop will always be executed once, even if the condition is false, because the code is executed before the condition is tested. do { code to be executed } while (var<=endvalue)

Example

PAGE 50 OF 185!

PHP PROGRAMMING !

<html> <body> <script type="text/javascript"> var i=0 do { document.write("The number is " + i) document.write("<br />") i=i+1 } while (i<0) </script> </body> </html>

Result
The number is 0

JavaScript Break and Continue JavaScript break and continue Statements


There are two special statements that can be used inside loops: break and continue.

Break
The break command will break the loop and continue executing the code that follows after the loop (if any).

Example
<html> <body> <script type="text/javascript"> var i=0 for (i=0;i<=10;i++) { if (i==3){break} document.write("The number is " + i) document.write("<br />") } </script> </body> </html>

Result

PAGE 51 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

The number is 0 The number is 1 The number is 2

Continue
The continue command will break the current loop and continue with the next value.

Example
<html> <body> <script type="text/javascript"> var i=0 for (i=0;i<=10;i++) { if (i==3){continue} document.write("The number is " + i) document.write("<br />") } </script> </body> </html>

Result
The number is 0 The number is 1 The number is 2 The number is 4 The number is 5 The number is 6 The number is 7 The number is 8 The number is 9 The number is 10

JavaScript Array
An array is a variable that can store many variables within it. Many programmers have seen arrays in other languages, and they aren't that different in JavaScript. The following points should always be remembered when using arrays in JavaScript: The array is a special type of variable. Values are stored into an array by using the array name and by stating the location in the array you wish to store the value in brackets. Example: myArray[2] = "Hello World"; Values in an array are accessed by the array name and location of the value. Example: myArray[2]; JavaScript has built-in functions for arrays, so check out these built-in array functions before writing the code yourself!
PAGE 52 OF 185! !

PHP PROGRAMMING !

JavaScript Code:
<script type="text/javascript"> <!-var myArray = new Array(); myArray[0] = "Football"; myArray[1] = "Baseball"; myArray[2] = "Cricket"; document.write(myArray[0] + myArray[1] + myArray[2]); //--> </script>

Display:
FootballBaseballCricket

JavaScript Code:
<script type="text/javascript"> <!-var myArray2= new Array(); myArray2[0] = "Football"; myArray2[1] = "Baseball"; myArray2[2] = "Cricket"; myArray2.sort(); document.write(myArray2[0] + myArray2[1] + myArray2[2]); //--> </script>

Display:
BaseballCricketFootball

What is Functions?
A function contains some code that will be executed by an event or a call to that function. A function is a set of statements. You can reuse functions within the same script, or in other documents. You define functions at the beginning of a file (in the head section), and call them later in the document. It is now time to take a lesson about the alert-box: This is JavaScript's method to alert the user. Alert("This is a message")

How to Define a Function


To create a function you define its name, any values ("arguments"), and some statements:

PAGE 53 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

function myfunction(argument1,argument2,etc) { some statements } A function with no arguments must include the parentheses: function myfunction() { some statements } Arguments are variables used in the function. The variable values are values passed on by the function call. By placing functions in the head section of the document, you make sure that all the code in the function has been loaded before the function is called. Some functions return a value to the calling expression function result(a,b) { c=a+b return c }

How to Call a Function?


A function is not executed before it is called. You can call a function containing arguments: myfunction(argument1,argument2,etc) or without arguments: myfunction()

The return Statement


Functions that will return a result must use the "return" statement. This statement specifies the value which will be returned to where the function was called from. Say you have a function that returns the sum of two numbers:

PAGE 54 OF 185!

PHP PROGRAMMING !

function total(a,b) { result=a+b return result } When you call this function you must send two arguments with it:

sum=total(2,3)
The returned value from the function (5) will be stored in the variable called sum.

JavaScript Popup Boxes In JavaScript we can create three kind of popup boxes: Alert box, Confirm box, and Prompt box. Alert Box An alert box is often used if you want to make sure information comes through to the user. When an alert box pops up, the user will have to click "OK" to proceed. Syntax: alert("sometext")

Example:
<html> <head> <script type="text/javascript"> function show_alert() { alert("I am an alert box!"); } </script> </head> <body> <input type="button" onclick="show_alert()" value="Show alert box" /> </body> </html>
PAGE 55 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Confirm Box A confirm box is often used if you want the user to verify or accept something. When a confirm box pops up, the user will have to click either "OK" or "Cancel" to proceed. If the user clicks "OK", the box returns true. If the user clicks "Cancel", the box returns false. Syntax: confirm("sometext")

Example:
<html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Press a button"); if (r==true) { alert("You pressed OK!"); } else { alert("You pressed Cancel!"); } } </script> </head> <body> <input type="button" onclick="show_confirm()" value="Show confirm box" /> </body> </html> Prompt Box A prompt box is often used if you want the user to input a value before entering a page. When a prompt box pops up, the user will have to click either "OK" or "Cancel" to proceed after entering an input value. If the user clicks "OK" the box returns the input value. If the user clicks "Cancel" the box returns null. Syntax: prompt("sometext","defaultvalue")
PAGE 56 OF 185! !

PHP PROGRAMMING !

Example:
<html> <head> <script type="text/javascript"> function show_prompt() { var name=prompt("Please enter your name","Harry Potter"); if (name!=null && name!="") { document.write("Hello " + name + "! How are you today?"); } } </script> </head> <body> <input type="button" onclick="show_prompt()" value="Show prompt box" /> </body> </html>

Setting Date in javascript The setDate() method sets the day of the month to the date object.

Syntax Date.setDate(day) Example <!DOCTYPE html> <html> <body> <script> var d = new Date(); var x=d.setDate(14); document.write(x); } </script>
PAGE 57 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

</body> </html>

JavaScript Events
Events are actions that can be detected by JavaScript.

Events
By using JavaScript, we have the ability to create dynamic web pages. Events are actions that can be detected by JavaScript. Every element on a web page has certain events which can trigger JavaScript functions. For example, we can use the onClick event of a button element to indicate that a function will run when a user clicks on the button. We define the events in the HTML tags. Examples of events: A mouse click A web page or an image loading Mousing over a hot spot on the web page Selecting an input box in an HTML form Submitting an HTML form A keystroke The following table lists the events recognized by JavaScript: Note: Events are normally used in combination with functions, and the function will not be executed before the event occurs!

onload and onUnload


The onload and onUnload events are triggered when the user enters or leaves the page. The onload event is often used to check the visitor's browser type and browser version, and load the proper version of the web page based on the information. Both the onload and onUnload events are also often used to deal with cookies that should be set when a user enters or leaves a page. For example, you could have a popup asking for the user's name upon his first arrival to your page. The name is then stored in a cookie. Next time the visitor arrives at your page, you could have another popup saying something like: "Welcome John Doe!".

onFocus, onBlur and onChange


The onFocus, onBlur and onChange events are often used in combination with validation of form fields. Below is an example of how to use the onChange event. The checkEmail() function will be called whenever the user changes the content of the field:
PAGE 58 OF 185! !

PHP PROGRAMMING !

<input type="text" size="30" id="email" onchange="checkEmail()">;

onSubmit
The onSubmit event is used to validate ALL form fields before submitting it. Below is an example of how to use the onSubmit event. The checkForm() function will be called when the user clicks the submit button in the form. If the field values are not accepted, the submit should be cancelled. The function checkForm() returns either true or false. If it returns true the form will be submitted, otherwise the submit will be cancelled: <form method="post" action="xxx.htm" onsubmit="return checkForm()">

onMouseOver and onMouseOut


onMouseOver and onMouseOut are often used to create "animated" buttons. Below is an example of an onMouseOver event. An alert box appears when an onMouseOver event is detected: <a href="http://www.w3schools.com" onmouseover="alert('An onMouseOver event');return false"> <img src="sch.gif" width="100" height="30"> </a>

JavaScript Special Characters


In JavaScript you can add special characters to a text string by using the backslash sign. Insert Special Characters The backslash (\) is used to insert apostrophes, new lines, quotes, and other special characters into a text string. Look at the following JavaScript code: var txt="We are the so-called "Vikings" from the north." document.write(txt) In JavaScript, a string is started and stopped with either single or double quotes. This means that the string above will be chopped to: We are the so-called To solve this problem, you must place a backslash (\) before each double quote in "Viking". This turns each double quote into a string literal: var txt="We are the so-called \"Vikings\" from the north." document.write(txt)
PAGE 59 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

JavasScript will now output the proper text string: We are the so-called "Vikings" from the north. Here is another example: document.write ("You \& me are singing!") The example above will produce the following output: You & me are singing! The table below lists other special characters that can be added to a text string with the backslash sign:

Code \' \" \& \\ \n \r \t \b \f JavaScript Guidelines

Outputs single quote double quote ampersand backslash new line carriage return tab backspace form feed

Some other important things to know when scripting with JavaScript. JavaScript is Case Sensitive A function named "myfunction" is not the same as "myFunction" and a variable named "myVar" is not the same as "myvar". JavaScript is case sensitive - therefore watch your capitalization closely when you create or call variables, objects and functions. White Space JavaScript ignores extra spaces. You can add white space to your script to make it more readable. The following lines are equivalent: name="Hege" name = "Hege" Break up a Code Line You can break up a code line within a text string with a backslash. The example below will be displayed properly: document.write("Hello \ World!")
PAGE 60 OF 185! !

PHP PROGRAMMING !

However, you cannot break up a code line like this: document.write \ ("Hello World!") Comments You can add comments to your script by using two slashes //: //this is a comment document.write("Hello World!") or by using /* and */ (this creates a multi-line comment block): /* This is a comment block. It contains several lines */ document.write("Hello World!") JavaScript Objects Introduction JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types. Object Oriented Programming JavaScript is an Object Oriented Programming (OOP) language. An OOP language allows you to define your own objects and make your own variable types. However, creating your own objects will be explained later, in the Advanced JavaScript section. We will start by looking at the built-in JavaScript objects, and how they are used. The next pages will explain each built-in JavaScript object in detail. Note that an object is just a special kind of data. An object has properties and methods. Properties Properties are the values associated with an object. In the following example we are using the length property of the String object to return the number of characters in a string: <script type="text/javascript"> var txt="Hello World!" document.write(txt.length) </script> The output of the code above will be: 12

PAGE 61 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Methods Methods are the actions that can be performed on objects. In the following example we are using the toUpperCase() method of the String object to display a text in uppercase letters: <script type="text/javascript"> var str="Hello world!" document.write(str.toUpperCase()) </script> The output of the code above will be: HELLO WORLD! JavaScript String Object The String object is used to manipulate a stored piece of text. String object The String object is used to manipulate a stored piece of text. Examples of use: The following example uses the length property of the String object to find the length of a string: var txt="Hello world!" document.write(txt.length) The code above will result in the following output: 12 The following example uses the toUpperCase() method of the String object to convert a string to uppercase letters: var txt="Hello world!" document.write(txt.toUpperCase()) The code above will result in the following output: HELLO WORLD!

JavaScript Date Object The Date object is used to work with dates and times. Defining Dates The Date object is used to work with dates and times.
PAGE 62 OF 185! !

PHP PROGRAMMING !

We define a Date object with the new keyword. The following code line defines a Date object called myDate: var myDate=new Date() Note: The Date object will automatically hold the current date and time as its initial value! Manipulate Dates We can easily manipulate the date by using the methods available for the Date object. In the example below we set a Date object to a specific date (14th January 2010): var myDate=new Date() myDate.setFullYear(2010,0,14) And in the following example we set a Date object to be 5 days into the future: var myDate=new Date() myDate.setDate(myDate.getDate()+5) Note: If adding five days to a date shifts the month or year, the changes are handled automatically by the Date object itself! Comparing Dates The Date object is also used to compare two dates. The following example compares today's date with the 14th January 2010: var myDate=new Date() myDate.setFullYear(2010,0,14) var today = new Date() if (myDate>today) alert("Today is before 14th January 2010") else alert("Today is after 14th January 2010")

JavaScript Array Object The Array object is used to store a set of values in a single variable name. Defining Arrays The Array object is used to store a set of values in a single variable name. We define an Array object with the new keyword. The following code line defines an Array object called myArray: var myArray=new Array()
PAGE 63 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

There are two ways of adding values to an array (you can add as many values as you need to define as many variables you require). 1: var mycars=new Array() mycars[0]="Saab" mycars[1]="Volvo" mycars[2]="BMW" You could also pass an integer argument to control the array's size: var mycars=new Array(3) mycars[0]="Saab" mycars[1]="Volvo" mycars[2]="BMW" 2: var mycars=new Array("Saab","Volvo","BMW") Note: If you specify numbers or true/false values inside the array then the type of variables will be numeric or Boolean instead of string. Accessing Arrays You can refer to a particular element in an array by referring to the name of the array and the index number. The index number starts at 0. The following code line: document.write(mycars[0]) will result in the following output: Saab

Modify Values in Existing Arrays To modify a value in an existing array, just add a new value to the array with a specified index number: mycars[0]="Opel" Now, the following code line: document.write(mycars[0]) will result in the following output: Opel

PAGE 64 OF 185!

PHP PROGRAMMING !

JavaScript Math Object The Math object allows you to perform common mathematical tasks. Math Object The Math object allows you to perform common mathematical tasks. The Math object includes several mathematical values and functions. You do not need to define the Math object before using it. Mathematical Values JavaScript provides eight mathematical values (constants) that can be accessed from the Math object. These are: E, PI, square root of 2, square root of 1/2, natural log of 2, natural log of 10, base-2 log of E, and base-10 log of E. You may reference these values from your JavaScript like this: Math.E Math.PI Math.SQRT2 Math.SQRT1_2 Math.LN2 Math.LN10 Math.LOG2E Math.LOG10E

Mathematical Methods In addition to the mathematical values that can be accessed from the Math object there are also several functions (methods) available.
Examples of functions (methods):

The following example uses the round() method of the Math object to round a number to the nearest integer: document.write(Math.round(4.7)) The code above will result in the following output: 5 The following example uses the random() method of the Math object to return a random number between 0 and 1: document.write(Math.random())
The code above can result in the following output:

0.8669997601016495
PAGE 65 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

The following example uses the floor() and random() methods of the Math object to return a random number between 0 and 10: document.write(Math.floor(Math.random()*11)) The code above can result in the following output: 3

JavaScript Timing Events With JavaScript, it is possible to execute some code NOT immediately after a function is called, but after a specified time interval. This is called timing events. JavaScript Timing Events With JavaScript, it is possible to execute some code NOT immediately after a function is called, but after a specified time interval. This is called timing events. It's very easy to time events in JavaScript. The two key methods that are used are: setTimeout() - executes a code some time in the future clearTimeout() - cancels the setTimeout()
Note: The setTimeout()

and clearTimeout() are both methods of the HTML DOM Window object.

setTimeout() Syntax var t=setTimeout("javascript statement",milliseconds) The setTimeout() method returns a value - In the statement above, the value is stored in a variable called t. If you want to cancel this setTimeout(), you can refer to it using the variable name. The first parameter of setTimeout() is a string that contains a JavaScript statement. This statement could be a statement like "alert('5 seconds!')" or a call to a function, like "alertMsg()". The second parameter indicates how many milliseconds from now you want to execute the first parameter. Note: There are 1000 milliseconds in one second. clearTimeout() Syntax clearTimeout(setTimeout_variable) Example When the button is clicked in the example below, an alert box will be displayed after 5 seconds.
PAGE 66 OF 185! !

PHP PROGRAMMING !

<html> <head> <script> var c=setTimeout("alert('Press the OK button to continue')",5000); function clr() { clearTimeout(c); alert("The setTimeout() method was cancelled"); } </script> </head> <body> <form> <input type="button" value="OK" onclick="clr()"> </form> </html> What is RegExp? A regular expression is an object that describes a pattern of characters. When you search in a text, you can use a pattern to describe what you are searching for. A simple pattern can be one single character. A more complicated pattern can consist of more characters, and can be used for parsing, format checking, substitution and more. Regular expressions are used to perform powerful pattern-matching and "search-and-replace" functions on text. Syntax var patt=new RegExp(pattern,modifiers); or more simply: var patt=/pattern/modifiers; pattern specifies the pattern of an expression modifiers specify if a search should be global, case-insensitive, etc. RegExp Modifiers Modifiers are used to perform case-insensitive and global searches. The i modifier is used to perform case-insensitive matching.
PAGE 67 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

The g modifier is used to perform a global match (find all matches rather than stopping after the first match). Modifiers Modifiers are used to perform case-insensitive and global searches: Modifier i g m Brackets Brackets are used to find a range of characters: Description Perform case-insensitive matching Perform a global match (find all matches rather than stopping after the first match) Perform multiline matching

Expression [abc] [^abc] [0-9] [A-Z] [a-z] [A-z] [adgk] [^adgk] (red|blue|green)
Metacharacters

Description Find any character between the brackets Find any character not between the brackets Find any digit from 0 to 9 Find any character from uppercase A to uppercase Z Find any character from lowercase a to lowercase z Find any character from uppercase A to lowercase z Find any character in the given set Find any character outside the given set Find any of the alternatives specified

Metacharacters are characters with a special meaning:

Metacharacter . \w \W \d \D
PAGE 68 OF 185!

Description Find a single character, except newline or line terminator Find a word character Find a non-word character Find a digit Find a non-digit character
!

PHP PROGRAMMING !

\s \S \b \B \0 \n \f \t

Find a whitespace character Find a non-whitespace character Find a match at the beginning/end of a word Find a match not at the beginning/end of a word Find a NUL character Find a new line character Find a form feed character Find a tab character

Working Example: Changing Text with innerHTML Each HTML element has an innerHTML property that defines both the HTML code and the text that occurs between that element's opening and closing tag. By changing an element's innerHTML after some user interaction, you can make much more interactive pages. However, using innerHTML requires some preparation if you want to be able to use it easily and reliably. First, you must give the element you wish to change an id. With that id in place you will be able to use the getElementById function, which works on all browsers. After you have that set up you can now manipulate the text of an element. To start off, let's try changing the text inside a bold tag. JavaScript Code: <script type="text/javascript"> function changeText(){ document.getElementById('boldStuff').innerHTML = 'Fred Flinstone'; } </script> <p>Welcome to the site <b id='boldStuff'>dude</b> </p> <input type='button' onclick='changeText()' value='Change Text'/> Display: Welcome to the site dude

PAGE 69 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Changing image in javascript


<html> <head> <script type="text/javascript"> function image() { document.getElementById('txt').src="123.gif"; //document.getElementById('txt').title="khalsa"; } function nn() { document.getElementById('txt').src="apple.jpg"; } </script> </head> <body>

<div id="text"> <img src="apple.jpg" id="txt" onmouseover="image()" onmouseout="nn()"/> </div> </body> </html> Changing Background Color o'clock <html> <head> <script type="text/javascript"> function bcol(bgc) { document.getElementById('e').style.backgroundColor=bgc;
PAGE 70 OF 185! !

PHP PROGRAMMING !

} </script> </head> <body id="e"> <div style="background-color:red;height:20px;width:20px" onclick="bcol('red')"></div> <div style="background-color:green;height:20px;width:20px" onclick="bcol('green')"></div> <div style="background-color:black;height:20px;width:20px" onclick="bcol('black')"</div> </body> </html>

SLIDER IN JAVASCRIPT
<html> <head> <script type="text/javascript"> <!-var image1=new Image() image1.src="firstcar.gif" var image2=new Image() image2.src="secondcar.gif" var image3=new Image() image3.src="thirdcar.gif" //--> </script> </head> <body> <img src="firstcar.gif" name="slide" width="100" height="56" /> <script> <!-//variable that will increment through the images var step=1
PAGE 71 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<3) step++ else step=1 //call function "slideit()" every 2.5 seconds setTimeout("slideit()",2500) } slideit() //--> </script> </body> </html>

JavaScript Summary
This tutorial has taught you how to add JavaScript to your HTML pages, to make your web site more dynamic and interactive. You have learned how to create responses to events, validate forms and how to make different scripts run in response to different scenarios. You have also learned how to create and use objects, and how to use JavaScript's built-in objects.

PAGE 72 OF 185!

PHP PROGRAMMING !

PHP
PHP is a powerful server-side scripting language for creating dynamic and interactive websites.PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. PHP is perfectly suited for Web development and can be embedded directly into the HTML code.The PHP syntax is very similar to Perl and C. PHP is often used together with Apache (web server) on various operating systems. It also supports ISAPI and can be used with Microsoft's IIS on Windows.

What is PHP?

PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) PHP is an open source software PHP is free to download and use What is a PHP File?

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", ".php3", or ".phtml" What is MySQL?

MySQL is a database server MySQL is ideal for both small and large applications MySQL supports standard SQL MySQL compiles on a number of platforms MySQL is free to download and use PHP + MySQL

PHP combined with MySQL are cross-platform (you can develop in Windows and serve on a Unix platform) Why PHP?

PHP runs on different platforms (Windows, Linux, Unix, etc.) PHP is compatible with almost all servers used today (Apache, IIS, etc.) PHP is FREE to download from the official PHP resource: www.php.net PHP is easy to learn and runs efficiently on the server side
! NETMAX TECHNOLOGIES

PAGE 73 OF 185!

SUBJECT: HTML BASICS!

Download PHP Download PHP for free here: http://www.php.net/downloads.php Download MySQL Database Download MySQL for free here: http://www.mysql.com/downloads/index.html Download Apache Server Download Apache for free here: http://httpd.apache.org/download.cgi PHP code is executed on the server, and the plain HTML result is sent to the browser. Or Download Wamp,Xampp,Lamp Server WAMP-Windows software with Apache,Mysql and PHP XAMPP-Any Platform software with Apache,Mysql and PHP,PERL LAMP-Linux software with Apache,Mysql and PHP

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. On servers with shorthand support enabled you can start a scripting block with <? and end with ?>. For maximum compatibility, we recommend that you use the standard form (<?php) rather than the shorthand form.

<?php ?>
A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. Below, we have an example of a simple PHP script which sends the text "Hello World" to the browser: <html> <body> <?php echo "Hello World"; ?> </body> </html> Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to
PAGE 74 OF 185! !

PHP PROGRAMMING !

distinguish one set of instructions from another. There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World". Note: The file must have the .php extension. If the file has a .html extension, the PHP code will not be executed. Comments in PHP In PHP, we use // to make a single-line comment or /* and */ to make a large comment block. <html> <body> <?php //This is a comment /* This is a comment block */ ?> </body> </html> Variables in PHP Variables are used for storing a values, like text strings, numbers or arrays. When a variable is set it can be used over and over again in your script All variables in PHP start with a $ sign symbol. The correct way of setting a variable in PHP: $var_name = value; New PHP programmers often forget the $ sign at the beginning of the variable. In that case it will not work. Let's try creating a variable with a string, and a variable with a number: <?php $txt = "Hello World!"; $number = 16; ?>

PAGE 75 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

PHP (a Loosely Typed Language) In PHP a variable does not need to be declared before being set. In the example above, you see that you do not have to tell PHP which data type the variable is. PHP automatically converts the variable to the correct data type, depending on how they are set. In a strongly typed programming language, you have to declare (define) the type and name of the variable before using it. In PHP the variable is declared automatically when you use it. Variable Naming Rules

A variable name must start with a letter or an underscore "_" A variable name can only contain alpha-numeric characters and underscores (a-z, A-Z, 0-9, and _) A variable name should not contain spaces. If a variable name is more than one word, it should be separated with underscore ($my_string), or with capitalization ($myString)

PHP Operators This section lists the different operators used in PHP. Arithmetic Operators

Operator Description + Addition * / % ++ -Operator = += -= *=

Example x=2 x+2 Subtraction x=2 5-x Multiplication x=4 x*5 Division 15/5 5/2 Modulus (division remainder) 5%2 10%8 10%2 Increment x=5 x++ Decrement x=5 x-Is The Same As x=y x=x+y x=x-y x=x*y
!

Result 4 3 20 3 2.5 1 2 0 x=6 x=4

Assignment Operators

Example x=y x+=y x-=y x*=y

PAGE 76 OF 185!

PHP PROGRAMMING !

/= .= %= Operator == != > < >= <=

x/=y x.=y x%=y Description is equal to is not equal is greater than is less than is greater than or equal to is less than or equal to

x=x/y x=x.y x=x%y Example 5==8 returns false 5!=8 returns true 5>8 returns false 5<8 returns true 5>=8 returns false 5<=8 returns true Example x=6 y=3 (x < 10 && y > 1) returns true x=6 y=3 (x==5 || y==5) returns false x=6 y=3 !(x==y) returns true

Comparison Operators

Logical Operators

Operator Description && and

||

or

not

The if, elseif and else statements in PHP are used to perform different actions based on different conditions. 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.

if...else statement - use this statement if you want to execute a set of code when a condition is true and another if the condition is not true elseif statement - is used with the if...else statement to execute a set of code if one of several condition are true The If...Else Statement

PAGE 77 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

If you want to execute some code if a condition is true and another code if a condition is false, use the if....else statement.

Syntax if (condition) code to be executed if condition is true; else code to be executed if condition is false;

Example The following example will output "Have a nice weekend!" if the current day is Friday, otherwise it will output "Have a nice day!": <html> <body> <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; else echo "Have a nice day!"; ?> </body> </html> If more than one line should be executed if a condition is true/false, the lines should be enclosed within curly braces: <html> <body> <?php $d=date("D"); if ($d=="Fri") { echo "Hello!<br />"; echo "Have a nice weekend!"; echo "See you on Monday!"; } ?> </body> </html>

The ElseIf Statement


PAGE 78 OF 185! !

PHP PROGRAMMING !

If you want to execute some code if one of several conditions are true use the elseif statement Syntax if (condition) code to be executed if condition is true; elseif (condition) code to be executed if condition is true; else code to be executed if condition is false; Example The following example will output "Have a nice weekend!" if the current day is Friday, and "Have a nice Sunday!" if the current day is Sunday. Otherwise it will output "Have a nice day!": <html> <body> <?php $d=date("D"); if ($d=="Fri") echo "Have a nice weekend!"; elseif ($d=="Sun") echo "Have a nice Sunday!"; else echo "Have a nice day!"; ?> </body> </html>

PHP Switch Statement The Switch statement in PHP is used to perform one of several different actions based on one of several different conditions. The Switch Statement If you want to select one of many blocks of code to be executed, use the Switch statement. The switch statement is used to avoid long blocks of if..elseif..else code. Syntax switch (expression) { case label1: code to be executed if expression = label1; break; case label2:
PAGE 79 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

code to be executed if expression = label2; break; default: code to be executed if expression is different from both label1 and label2; } Example This is how it works:

A single expression (most often a variable) is evaluated once The value of the expression is compared with the values for each case in the structure If there is a match, the code associated with that case is executed After a code is executed, break is used to stop the code from running into the next case The default statement is used if none of the cases are true

<html> <body> <?php switch ($x) { case 1: echo "Number 1"; break; case 2: echo "Number 2"; break; case 3: echo "Number 3"; break; default: echo "No number between 1 and 3"; } ?> </body> </html> Looping Looping statements in PHP are used to execute the same block of code a specified number of times. Very often when you write code, you want the same block of code to run a number of times. You can use looping statements in your code to perform this. In PHP we have the following looping statements:

while - loops through a block of code if and as long as a specified condition is true
!

PAGE 80 OF 185!

PHP PROGRAMMING !

do...while - loops through a block of code once, and then repeats the loop as long as a special condition is true for - loops through a block of code a specified number of times foreach - loops through a block of code for each element in an array

The while Statement The while statement will execute a block of code if and as long as a condition is true. Syntax

while (condition) code to be executed;


Example The following example demonstrates a loop that will continue to run as long as the variable i is less than, or equal to 5. i will increase by 1 each time the loop runs: <html> <body> <?php $i=1; while($i<=5) { echo "The number is " . $i . "<br />"; $i++; } ?> </body> </html> Do...While The do...while statement will execute a block of code at least once - it then will repeat the loop as long as a condition is true. Syntax do { code to be executed; } while (condition);

Example The following example will increment the value of i at least once, and it will continue incrementing the
PAGE 81 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

variable i as long as it has a value of less than 5: <html> <body> <?php $i=0; do { $i++; echo "The number is " . $i . "<br />"; } while ($i<5); ?> </body> </html>

The For Loop The for statement is the most advanced of the loops in PHP. In it's simplest form, the for statement is used when you know how many times you want to execute a statement or a list of statements. Syntax for (init; cond; incr) { code to be executed; } Parameters:

init: Is mostly used to set a counter, but can be any code to be executed once at the beginning of the loop statement. cond: Is evaluated at beginning of each loop iteration. If the condition evaluates to TRUE, the loop continues and the code executes. If it evaluates to FALSE, the execution of the loop ends. incr: Is mostly used to increment a counter, but can be any code to be executed at the end of each loop.

Note: Each of the parameters can be empty or have multiple expressions separated by commas.

cond: All expressions separated by a comma are evaluated but the result is taken from the last part. This parameter being empty means the loop should be run indefinitely. This is useful when using a conditional break statement inside the loop for ending the loop.

Example The following example prints the text "Hello World!" five times:
PAGE 82 OF 185! !

PHP PROGRAMMING !

<html> <body> <?php for ($i=1; $i<=5; $i++) { echo "Hello World!<br />"; } ?> </body> </html> An array can store one or more values in a single variable name. What is an array? When working with PHP, sooner or later, you might want to create many similar variables. Instead of having many similar variables, you can store the data as elements in an array. Each element in the array has its own ID so that it can be easily accessed. There are three different kind of arrays:

Numeric array - An array with a numeric ID key Associative array - An array where each ID key is associated with a value Multidimensional array - An array containing one or more arrays

Numeric Arrays A numeric array stores each element with a numeric ID key. There are different ways to create a numeric array. Example 1 In this example the ID key is automatically assigned: $names = array("Purnima","Harpreet","Ginni");

Example 2 In this example we assign the ID key manually: $names[0] = "Purnima"; $names[1] = "Harpreet"; $names[2] = "Ginni"; The ID keys can be used in a script:

PAGE 83 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<?php $names[0] = "Purnima"; $names[1] = "Harpreet"; $names[2] = "Ginni"; echo $names[1] . " and " . $names[2] . " are ". $names[0] . "'s neighbors"; ?> The code above will output: Ginni and Harpreet are Purnima neighbors

Associative Array An associative array, each ID key is associated with a value. When storing data about specific named values, a numerical array is not always the best way to do it. With associative arrays we can use the values as keys and assign values to them. Example 1 In this example we use an array to assign ages to the different persons: $ages = array("Sudhanshu"=>32, "Jai"=>30, "Vivek"=>34); Example 2 This example is the same as example 1, but shows a different way of creating the array: $ages['Sudhanshu'] = 32; $ages['Jai'] = 30; $ages['Vivek'] = 34; The ID keys can be used in a script: <?php $ages['sudhanshu'] = 32; $ages['Jai'] = 30; $ages['Vivek'] = 34; echo "Peter is " . $ages['Peter'] . " years old."; ?> The code above will output:

Sudhanshu is 32 years old.


Multidimensional Arrays In a multidimensional array, each element in the main array can also be an array. And each element in the sub-array can be an array, and so on. Example In this example we create a multidimensional array, with automatically assigned ID keys:
PAGE 84 OF 185! !

PHP PROGRAMMING !

$products=array('Samsung'=>array( 'color'=>'red', 'price'=>20000) ,'lg'=>array( 'color'=>'black', 'price'=>30000) ); The array above would look like this if written to the output: Array ( [Samsung] => Array ( [color] => red [price] => 20000 [2] => Megan ), [lg] => Array ( [color] => balck [price]=>30000 ) )

Output Lets try displaying a single value from the array above: echo "Price of Samsung is" . $products['Samsung']['Price'] ; The code above will output: Price of Samsung is 20000 for..each statement The foreach statement is used to loop through arrays. For every loop, the value of the current array element is assigned to $value (and the array pointer is moved by one) - so on the next loop, you'll be looking at the next element. Syntax foreach (array as value) { code to be executed; }

PAGE 85 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Example The following example demonstrates a loop that will print the values of the given array: <html> <body> <?php $arr=array(Sudhanshu=>22,Harpreet=>24,jai=>44); foreach ($arr as $key=>$value) { echo Age of: .$key.is . $value . "<br />"; } ?> </body> </html>
Output Age of Sudhanshu is 22 Age of Harpreet is 24 Age of jai is 44

The real power of PHP comes from its functions. In PHP - there are more than 700 built-in functions available.

PHP Functions
In this tutorial we will show you how to create your own functions. Functions are of two types 1.Inbuilt functions 2.User Defined Functions Inbuilt String Functions Strings in PHP String variables are used for values that contains character strings. In this tutorial we are going to look at some of the most common functions and operators used to manipulate strings in PHP. After we create a string we can manipulate it. A string can be used directly in a function or it can be stored in a variable. Below, the PHP script assigns the string "Hello World" to a string variable called $txt:

PAGE 86 OF 185!

PHP PROGRAMMING !

<?php $txt="Hello World"; echo $txt; ?> The output of the code above will be: Hello World Now, lets try to use some different functions and operators to manipulate our string. The Concatenation Operator There is only one string operator in PHP. The concatenation operator (.) is used to put two string values together. To concatenate two variables together, use the dot (.) operator: <?php $txt1="Hello World"; $txt2="1234"; echo $txt1 . " " . $txt2; ?> The output of the code above will be: Hello World 1234 If we look at the code above you see that we used the concatenation operator two times. This is because we had to insert a third string. Between the two string variables we added a string with a single character, an empty space, to separate the two variables. Using the strlen() function The strlen() function is used to find the length of a string. Let's find the length of our string "Hello world!": <?php echo strlen("Hello world!"); ?> The output of the code above will be: 12 The length of a string is often used in loops or other functions, when it is important to know when the string ends. (i.e. in a loop, we would want to stop the loop after the last character in the string)

PHP addcslashes() Function Definition and Usage The addcslashes() function returns a string with backslashes in front of the specified characters.
PAGE 87 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Syntax addcslashes(string,characters) Parameter string characters Example: $str="what a nice movie"; $res=addcslashes($str5,nve); echo $res; Output: Description Required. Specifies the string to check Required. Specifies the characters or range of characters to be affected by addcslashes()

what a \nic\e mo\vi\e


PHP addslashes() Function Definition and Usage The addslashes() function returns a string with backslashes in front of predefined characters. The predefined characters are: Syntax addslashes(string) Parameter string Example: $str5="what's going on"; $res5=addslashes($str5); echo $res5; Output: Description Required. Specifies the string to check single quote (') double quote (") backslash (\) NULL

what\'s going on
PHP chr() Function

PAGE 88 OF 185!

PHP PROGRAMMING !

Definition and Usage The chr() function returns a character from the specified ASCII value. Syntax chr(ascii) Parameter ascii Description Required. An ASCII value

Example: $res=chr(65); echo $res; Output A PHP nl2br() Function Definition and Usage The nl2br() function inserts HTML line breaks (<br />) in front of each newline (\n) in a string. Syntax nl2br(string) Parameter string Description Required. Specifies the string to check

PHP strip_tags() Function Definition and Usage The strip_tags() function strips a string from HTML, XML, and PHP tags. Syntax strip_tags(string,allow) Parameter string
PAGE 89 OF 185!

Description Required. Specifies the string to check


! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

allow

Optional. Specifies allowable tags. These tags will not be removed

PHP stripcslashes() Function Definition and Usage The stripcslashes() function removes backslashes added by the addcslashes() function. Syntax stripcslashes(string) Parameter string Description Required. Specifies the string to check

PHP stripslashes() Function Definition and Usage The stripslashes() function removes backslashes added by the addslashes() function. Syntax stripslashes(string) Parameter string PHP htmlentities() Function Definition and Usage The htmlentities() function converts characters to HTML entities. Syntax htmlentities(string,quotestyle,character-set) Parameter string quotestyle Description Required. Specifies the string to convert Optional. Specifies how to encode single and double quotes. The available quote styles are: ENT_COMPAT - Default. Encodes only double quotes ENT_QUOTES - Encodes double and single quotes ENT_NOQUOTES - Does not encode any quotes
PAGE 90 OF 185! !

Description Required. Specifies the string to check

PHP PROGRAMMING !

character-set

Optional. A string that specifies which character-set to use. Allowed values are: ISO-8859-1 - Default. Western European ISO-8859-15 - Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1) UTF-8 - ASCII compatible multi-byte 8-bit Unicode cp866 - DOS-specific Cyrillic charset cp1251 - Windows-specific Cyrillic charset cp1252 - Windows specific charset for Western European KOI8-R - Russian BIG5 - Traditional Chinese, mainly used in Taiwan GB2312 - Simplified Chinese, national standard character set BIG5-HKSCS - Big5 with Hong Kong extensions Shift_JIS - Japanese EUC-JP - Japanese

Example : echo htmlentities("<h1>hello</h1>"); Output: <h1>hello</h1> PHP htmlspecialchars() Function Definition and Usage The htmlspecialchars() function converts some predefined characters to HTML entities. The predefined characters are: & (ampersand) becomes &amp; " (double quote) becomes &quot; ' (single quote) becomes &#039; < (less than) becomes &lt; > (greater than) becomes &gt;
! NETMAX TECHNOLOGIES

PAGE 91 OF 185!

SUBJECT: HTML BASICS!

Syntax htmlspecialchars(string,quotestyle,character-set) Parameter string quotestyle Description Required. Specifies the string to convert Optional. Specifies how to encode single and double quotes. The available quote styles are: ENT_COMPAT - Default. Encodes only double quotes ENT_QUOTES - Encodes double and single quotes ENT_NOQUOTES - Does not encode any quotes Optional. A string that specifies which character-set to use. Allowed values are: ISO-8859-1 - Default. Western European ISO-8859-15 - Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1) UTF-8 - ASCII compatible multi-byte 8-bit Unicode cp866 - DOS-specific Cyrillic charset cp1251 - Windows-specific Cyrillic charset cp1252 - Windows specific charset for Western European KOI8-R - Russian BIG5 - Traditional Chinese, mainly used in Taiwan GB2312 - Simplified Chinese, national standard character set BIG5-HKSCS - Big5 with Hong Kong extensions Shift_JIS - Japanese EUC-JP - Japanese

character-set

PAGE 92 OF 185!

PHP PROGRAMMING !

PHP html_entity_decode() Function Definition and Usage The html_entity_decode() function converts HTML entities to characters. The html_entity_decode() function is the opposite of htmlentities(). Syntax html_entity_decode(string,quotestyle,character-set) Parameter string quotestyle Description Required. Specifies the string to decode Optional. Specifies how to decode single and double quotes. The available quote styles are: ENT_COMPAT - Default. Decodes only double quotes ENT_QUOTES - Decodes double and single quotes ENT_NOQUOTES - Does not decode any quotes

PAGE 93 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

character-set

Optional. A string that specifies which character-set to use. Allowed values are: ISO-8859-1 - Default. Western European ISO-8859-15 - Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1) UTF-8 - ASCII compatible multi-byte 8-bit Unicode cp866 - DOS-specific Cyrillic charset cp1251 - Windows-specific Cyrillic charset cp1252 - Windows specific charset for Western European KOI8-R - Russian BIG5 - Traditional Chinese, mainly used in Taiwan GB2312 - Simplified Chinese, national standard character set BIG5-HKSCS - Big5 with Hong Kong extensions Shift_JIS - Japanese EUC-JP - Japanese

PHP htmlspecialchars() Function Definition and Usage The htmlspecialchars() function converts some predefined characters to HTML entities. The predefined characters are: Syntax htmlspecialchars(string,quotestyle,character-set) & (ampersand) becomes &amp; " (double quote) becomes &quot; ' (single quote) becomes &#039; < (less than) becomes &lt; > (greater than) becomes &gt;

PAGE 94 OF 185!

PHP PROGRAMMING !

Parameter string quotestyle

Description Required. Specifies the string to convert Optional. Specifies how to encode single and double quotes. The available quote styles are: ENT_COMPAT - Default. Encodes only double quotes ENT_QUOTES - Encodes double and single quotes ENT_NOQUOTES - Does not encode any quotes Optional. A string that specifies which character-set to use. Allowed values are: ISO-8859-1 - Default. Western European ISO-8859-15 - Western European (adds the Euro sign + French and Finnish letters missing in ISO-8859-1) UTF-8 - ASCII compatible multi-byte 8-bit Unicode cp866 - DOS-specific Cyrillic charset cp1251 - Windows-specific Cyrillic charset cp1252 - Windows specific charset for Western European KOI8-R - Russian BIG5 - Traditional Chinese, mainly used in Taiwan GB2312 - Simplified Chinese, national standard character set BIG5-HKSCS - Big5 with Hong Kong extensions Shift_JIS - Japanese EUC-JP - Japanese

character-set

PAGE 95 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

PHP md5() Function Definition and Usage The md5() function calculates the MD5 hash of a string. The md5() function uses the RSA Data Security, Inc. MD5 Message-Digest Algorithm. From RFC 1321 - The MD5 Message-Digest Algorithm: "The MD5 message-digest algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a publickey cryptosystem such as RSA." This function returns the calculated MD5 hash on success, or FALSE on failure. Syntax md5(string,raw) Parameter string raw Description Required. The string to be calculated Optional. Specifies hex or binary output format: TRUE - Raw 16 character binary format FALSE - Default. 32 character hex number Note: This parameter was added in PHP 5.0

Example $str="Powerx123"; $res=md5($str); echo $res; Output 850225b028a7f49d00d47e662ab65220

PHP sha1() Function Definition and Usage The sha1() function calculates the SHA-1 hash of a string. The sha1() function uses the US Secure Hash Algorithm 1.

PAGE 96 OF 185!

PHP PROGRAMMING !

From RFC 3174 - The US Secure Hash Algorithm 1: "SHA-1 produces a 160-bit output called a message digest. The message digest can then, for example, be input to a signature algorithm which generates or verifies the signature for the message. Signing the message digest rather than the message often improves the efficiency of the process because the message digest is usually much smaller in size than the message. The same hash algorithm must be used by the verifier of a digital signature as was used by the creator of the digital signature." This function returns the calculated SHA-1 hash on success, or FALSE on failure. Syntax sha1(string,raw) Parameter string raw Description Required. The string to be calculated Optional. Specify hex or binary output format: TRUE - Raw 20 character binary format FALSE - Default. 40 character hex number Note: This parameter was added in PHP 5.0

Example: $res1=sha1($str); echo $res1; Output 0360d45f013fabbe3fa538c35feec4cd5f59484a

PHP explode() Function Definition and Usage The explode() function breaks a string into an array. Syntax explode(separator,string,limit) Parameter separator string Description Required. Specifies where to break the string Required. The string to split

PAGE 97 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

limit Example: $str="happy new year 2013"; $a=explode(" ",$str,2); print_r($a); Output Array ( [0] => happy [1] => new year 2013 ) PHP implode() Function

Optional. Specifies the maximum number of array elements to return

The implode() function returns a string from the elements of an array. Syntax implode(separator,array) Parameter separator array Example: $b=array("hello","user","how","are","u"); $str2=implode(" ",$b); echo $str2; Output: hello user how are u PHP str_replace()Function Description Optional. Specifies what to put between the array elements. Default is "" (an empty string) Required. The array to join to a string

Definition and Usage The str_replace() function replaces some characters with some other characters in a string. This function works by the following rules: If the string to be searched is an array, it returns an array
PAGE 98 OF 185! !

PHP PROGRAMMING !

If the string to be searched is an array, find and replace is performed with every array element If both find and replace are arrays, and replace has fewer elements than find, an empty string will be used as replace If find is an array and replace is a string, the replace string will be used for every find value Syntax str_replace(find,replace,string,count) Parameter find replace string count Description Required. Specifies the value to find Required. Specifies the value to replace the value in find Required. Specifies the string to be searched Optional. A variable that counts the number of replacements

Tips and Notes Note: This function is case-sensitive. Use str_ireplace() to perform a case-insensitive search. Note: This function is binary-safe. Example 1 <?php echo str_replace("world","ginni","Hello world!"); ?> The output of the code above will be: Hello Ginni! Example 2 In this example we will demonstrate str_replace() with an array and a count variable: <?php $arr = array("blue","red","green","yellow"); print_r(str_replace("red","pink",$arr,$i)); echo "Replacements: $i"; ?> The output of the code above will be: Array (
PAGE 99 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

[0] => blue [1] => pink [2] => green [3] => yellow ) Replacements: 1 Example 3 In this example we will demonstrate str_replace() with less elements in replace than find: <?php $find = array("Hello","world"); $replace = array("B"); $arr = array("Hello","world","!"); print_r(str_replace($find,$replace,$arr)); ?> The output of the code above will be: Array ( [0] => B [1] => [2] => ! ) PHP strcmp() Function Definition and Usage The strcmp() function compares two strings. This function returns: 0 - if the two strings are equal <0 - if string1 is less than string2 >0 - if string1 is greater than string2 Syntax strcmp(string1,string2) Parameter string1 string2 Description Required. Specifies the first string to compare Required. Specifies the second string to compare

PAGE 100 OF 185!

PHP PROGRAMMING !

Tips and Notes Note: The strcmp() function is binary safe and case-sensitive. Example
<?php echo strcmp("Hello world!","Hello world!"); ?>

The output of the code above will be: 0 PHP strpos() Function Definition and Usage The strpos() function returns the position of the first occurrence of a string inside another string. If the string is not found, this function returns FALSE. Syntax strpos(string,find,start) Parameter string find start Description Required. Specifies the string to search Required. Specifies the string to find Optional. Specifies where to begin the search

Tips and Notes Note: The strpos() function is case-sensitive.

Example <?php echo strpos("Hello world!","wo"); ?> The output of the code above will be: 6

PAGE 101 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

PHP strrev() Function Definition and Usage The strrev() function reverses a string. Syntax strrev(string) Parameter string Description Required. Specifies the string to reverse

Example <?php echo strrev("Hello World!"); ?> The output of the code above will be: !dlroW olleH PHP substr() Function Definition and Usage The substr() function returns a part of a string. Syntax substr(string,start,length) Parameter string start Description Required. Specifies the string to return a part of Required. Specifies where to start in the string A positive number - Start at a specified position in the string A negative number - Start at a specified position from the end of the string 0 - Start at the first character in string Optional. Specifies the length of the returned string. Default is to the end of the string. A positive number - The length to be returned from the start parameter Negative number - The length to be returned from the end of the string
!

length

PAGE 102 OF 185!

PHP PROGRAMMING !

Tips and Notes Note: If start is a negative number and length is less than or equal to start, length becomes 0. Example 1 <?php echo substr("Hello world!",6); ?> The output of the code above will be:

world!
Example 2 <?php echo substr("Hello world!",6,5); ?>
The output of the code above will be:

world PHP chunk_split() Function chunk_split(string,length,end) Parameter string length end Description Required. Specifies the string to split Optional. A number that defines the length of the chunks. Default is 76 Optional. A string that defines what to place at the end of each chunk. Default is \r\n

PHP date() Function Definition and Usage The date() function formats a local time/date. Syntax date(format,timestamp) Parameter
PAGE 103 OF 185!

Description
! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

format

timestamp

Required. Specifies how to return the result: d - The day of the month (from 01 to 31) D - A textual representation of a day (three letters) j - The day of the month without leading zeros (1 to 31) l (lowercase 'L') - A full textual representation of a day N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday) S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j) w - A numeric representation of the day (0 for Sunday through 6 for Saturday) z - The day of the year (from 0 through 365) W - The ISO-8601 week number of year (weeks starting on Monday) F - A full textual representation of a month (January through December) m - A numeric representation of a month (from 01 to 12) M - A short textual representation of a month (three letters) n - A numeric representation of a month, without leading zeros (1 to 12) t - The number of days in the given month L - Whether it's a leap year (1 if it is a leap year, 0 otherwise) o - The ISO-8601 year number Y - A four digit representation of a year y - A two digit representation of a year a - Lowercase am or pm A - Uppercase AM or PM B - Swatch Internet time (000 to 999) g - 12-hour format of an hour (1 to 12) G - 24-hour format of an hour (0 to 23) h - 12-hour format of an hour (01 to 12) H - 24-hour format of an hour (00 to 23) i - Minutes with leading zeros (00 to 59) s - Seconds, with leading zeros (00 to 59) e - The timezone identifier (Examples: UTC, Atlantic/Azores) I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise) O - Difference to Greenwich time (GMT) in hours (Example: +0100) T - Timezone setting of the PHP machine (Examples: EST, MDT) Z - Timezone offset in seconds. The offset west of UTC is negative, and the offset east of UTC is positive (-43200 to 43200) c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00) r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200) U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) Optional.

PAGE 104 OF 185!

PHP PROGRAMMING !

User Defined Functions


A function is a block of code that can be executed whenever we need it. Creating PHP functions:

All functions start with the word "function()" Name the function - It should be possible to understand what the function does by its name. The name can start with a letter or underscore (not a number) Add a "{" - The function code starts after the opening curly brace Insert the function code Add a "}" - The function is finished by a closing curly brace

Example A simple function that writes my name when it is called: <html> <body> <?php function writeMyName() { echo "Kai Jim Refsnes"; } writeMyName(); ?> </body> </html> Use a PHP Function Now we will use the function in a PHP script: <html> <body> <?php function writeMyName() { echo "Kai Jim Refsnes"; } echo "Hello world!<br />"; echo "My name is "; writeMyName(); echo ".<br />That's right, "; writeMyName(); echo " is my name."; ?> </body> </html>
PAGE 105 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

The output of the code above will be: Hello world! My name is Kai Jim Refsnes. That's right, Kai Jim Refsnes is my name. PHP Functions - Adding parameters Our first function (writeMyName()) is a very simple function. It only writes a static string. To add more functionality to a function, we can add parameters. A parameter is just like a variable. You may have noticed the parentheses after the function name, like: writeMyName(). The parameters are specified inside the parentheses. Example 1 The following example will write different first names, but the same last name: <html> <body> <?php function writeMyName($fname) { echo $fname . " Refsnes.<br />"; } echo "My name is "; writeMyName("Kai Jim"); echo "My name is "; writeMyName("Hege"); echo "My name is "; writeMyName("Stale"); ?> </body> </html> The output of the code above will be: My name is Kai Jim Refsnes. My name is Hege Refsnes. My name is Stale Refsnes.

Example 2 The following function has two parameters:

PAGE 106 OF 185!

PHP PROGRAMMING !

<html> <body> <?php function writeMyName($fname,$punctuation) { echo $fname . " Refsnes" . $punctuation . "<br />"; } echo "My name is "; writeMyName("Kai Jim","."); echo "My name is "; writeMyName("Hege","!"); echo "My name is "; writeMyName("Stle","..."); ?> </body> </html> The output of the code above will be: My name is Kai Jim Refsnes. My name is Hege Refsnes! My name is Stle Refsnes... PHP Functions - Return values Functions can also be used to return values. Example <html> <body> <?php function add($x,$y) { $total = $x + $y; return $total; } echo "1 + 16 = " . add(1,16); ?> </body> </html> The output of the code above will be: 1 + 16 = 17 The PHP $_GET and $_POST variables are used to retrieve information from forms, like user input.

PAGE 107 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

PHP Form Handling


The most important thing to notice when dealing with HTML forms and PHP is that any form element in an HTML page will automatically be available to your PHP scripts. Form example: <html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> The example HTML page above contains two input fields and a submit button. When the user fills in this form and click on the submit button, the form data is sent to the "welcome.php" file. The "welcome.php" file looks like this: <html> <body> Welcome <?php echo $_POST["name"]; ?>.<br /> You are <?php echo $_POST["age"]; ?> years old. </body> </html> A sample output of the above script may be: Welcome Sud. You are 28 years old. The PHP $_GET and $_POST variables will be explained in the next chapters. Form Validation User input should be validated whenever possible. Client side validation is faster, and will reduce server load. However, any site that gets enough traffic to worry about server resources, may also need to worry about site security. You should always use server side validation if the form accesses a database. A good way to validate a form on the server is to post the form to itself, instead of jumping to a different page. The user will then get the error messages on the same page as the form. This makes it easier to discover the error. The $_GET variable is used to collect values from a form with method="get". The $_GET Variable The $_GET variable is an array of variable names and values sent by the HTTP GET method. The $_GET variable is used to collect values from a form with method="get". Information sent from a form with the GET method is visible to everyone (it will be displayed in the browser's address bar) and it has limits on the amount of information to send (max. 100 characters).
PAGE 108 OF 185! !

PHP PROGRAMMING !

Example <form action="welcome.php" method="get"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> When the user clicks the "Submit" button, the URL sent could look something like this: http://www.netmax.com/welcome.php?name=Peter&age=37 The "welcome.php" file can now use the $_GET variable to catch the form data (notice that the names of the form fields will automatically be the ID keys in the $_GET array): Welcome <?php echo $_GET["name"]; ?>.<br /> You are <?php echo $_GET["age"]; ?> years old!

Why use $_GET? When using the $_GET variable all variable names and values are displayed in the URL. So this method should not be used when sending passwords or other sensitive information! However, because the variables are displayed in the URL, it is possible to bookmark the page. This can be useful in some cases. Note: The HTTP GET method is not suitable on large variable values; the value cannot exceed 100 characters.

The $_REQUEST Variable The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods. Example Welcome <?php echo $_REQUEST["name"]; ?>.<br /> You are <?php echo $_REQUEST["age"]; ?> years old! The $_POST variable is used to collect values from a form with method="post". The $_POST Variable The $_POST variable is an array of variable names and values sent by the HTTP POST method. The $_POST variable is used to collect values from a form with method="post". Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.

PAGE 109 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Example <form action="welcome.php" method="post"> Enter your name: <input type="text" name="name" /> Enter your age: <input type="text" name="age" /> <input type="submit" /> </form> When the user clicks the "Submit" button, the URL will not contain any form data, and will look something like this: http://www.Netmax.com/welcome.php The "welcome.php" file can now use the $_POST variable to catch the form data (notice that the names of the form fields will automatically be the ID keys in the $_POST array): Welcome <?php echo $_POST["name"]; ?>.<br /> You are <?php echo $_POST["age"]; ?> years old! Why use $_POST?

Variables sent with HTTP POST are not shown in the URL Variables have no length limit

However, because the variables are not displayed in the URL, it is not possible to bookmark the page.

The $_REQUEST Variable The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE. The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods. Example. Welcome <?php echo $_REQUEST["name"]; ?>.<br /> You are <?php echo $_REQUEST["age"]; ?> years old!

The PHP date() function is used to format a time or a date. The PHP Date() Function The PHP date() function formats a timestamp to a more readable date and time. Syntax

date(format,timestamp)

PAGE 110 OF 185!

PHP PROGRAMMING !

Parameter format timestamp

Description Required. Specifies the format of the timestamp Optional. Specifies a timestamp. Default is the current date and time (as a timestamp)

PHP Date - What is a Timestamp? A timestamp is the number of seconds since January 1, 1970 at 00:00:00 GMT. This is also known as the Unix Timestamp. PHP Date - Format the Date The first parameter in the date() function specifies how to format the date/time. It uses letters to represent date and time formats. Here are some of the letters that can be used:

d - The day of the month (01-31) m - The current month, as a number (01-12) Y - The current year in four digits

Other characters, like"/", ".", or "-" can also be inserted between the letters to add additional formatting: <?php echo date("Y/m/d"); echo "<br />"; echo date("Y.m.d"); echo "<br />"; echo date("Y-m-d"); ?> The output of the code above could be something like this: 2006/07/11 2006.07.11 2006-07-11 Server Side Includes (SSI) are used to create functions, headers, footers, or elements that will be reused on multiple pages. Server Side Includes You can insert the content of a file into a PHP file before the server executes it, with the include() or require() function. The two functions are identical in every way, except how they handle errors. The include() function generates a warning (but the script will continue execution) while the require() function generates a fatal error (and the script execution will stop after the error). These two functions are used to create functions, headers, footers, or elements that can be reused on multiple pages. This can save the developer a considerable amount of time. This means that you can create a standard
PAGE 111 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

header or menu file that you want all your web pages to include. When the header needs to be updated, you can only update this one include file, or when you add a new page to your site, you can simply change the menu file (instead of updating the links on all web pages).

The include() Function The include() function takes all the text in a specified file and copies it into the file that uses the include function. Example 1 Assume that you have a standard header file, called "header.php". To include the header file in a page, use the include() function, like this: <html> <body> <?php include("header.php"); ?> <h1>Welcome to my home page</h1> <p>Some text</p> </body> </html>

Example 2 Now, let's assume we have a standard menu file that should be used on all pages (include files usually have a ".php" extension). Look at the "menu.php" file below: <html> <body> <a href="http://www.netmax.com/default.php">Home</a> | <a href="http://www.netmax.com/about.php">About Us</a> | <a href="http://www.netmax.com/contact.php">Contact Us</a> The three files, "default.php", "about.php", and "contact.php" should all include the "menu.php" file. Here is the code in "default.php": <?php include("menu.php"); ?> <h1>Welcome to my home page</h1> <p>Some text</p> </body> </html> If you look at the source code of the "default.php" in a browser, it will look something like this:

PAGE 112 OF 185!

PHP PROGRAMMING !

<html> <body> <a href="default.php">Home</a> | <a href="about.php">About Us</a> | <a href="contact.php">Contact Us</a> <h1>Welcome to my home page</h1> <p>Some text</p> </body> </html> And, of course, we would have to do the same thing for "about.php" and "contact.php". By using include files, you simply have to update the text in the "menu.php" file if you decide to rename or change the order of the links or add another web page to the site. The require() Function The require() function is identical to include(), except that it handles errors differently. The include() function generates a warning (but the script will continue execution) while the require() function generates a fatal error (and the script execution will stop after the error). If you include a file with the include() function and an error occurs, you might get an error message like the one below. PHP code: <html> <body> <?php include("wrongFile.php"); echo "Hello World!"; ?> </body> </html> Error message: Warning: include(wrongFile.php) [function.include]: failed to open stream: No such file or directory in C:\home\website\test.php on line 5 Warning: include() [function.include]: Failed opening 'wrongFile.php' for inclusion (include_path='.;C:\php5\pear') in C:\home\website\test.php on line 5 Hello World! Notice that the echo statement is still executed! This is because a Warning does not stop the script execution. Now, let's run the same example with the require() function. PHP code:
PAGE 113 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<html> <body> <?php require("wrongFile.php"); echo "Hello World!"; ?> </body> </html> Error message: Warning: require(wrongFile.php) [function.require]: failed to open stream: No such file or directory in C:\home\website\test.php on line 5 Fatal error: require() [function.require]: Failed opening required 'wrongFile.php' (include_path='.;C:\php5\pear') in C:\home\website\test.php on line 5 The echo statement was not executed because the script execution stopped after the fatal error. It is recommended to use the require() function instead of include(), because scripts should not continue executing if files are missing or misnamed. Create an Upload-File Form To allow users to upload files from a form can be very useful. Look at the following HTML form for uploading files: <html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> Notice the following about the HTML form above:

The enctype attribute of the <form> tag specifies which content-type to use when submitting the form. "multipart/form-data" is used when a form requires binary data, like the contents of a file, to be uploaded The type="file" attribute of the <input> tag specifies that the input should be processed as a file. For example, when viewed in a browser, there will be a browse-button next to the input field
!

PAGE 114 OF 185!

PHP PROGRAMMING !

Note: Allowing users to upload files is a big security risk. Only permit trusted users to perform file uploads.

Create The Upload Script The "upload_file.php" file contains the code for uploading a file: <?php if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } ?> By using the global PHP $_FILES array you can upload files from a client computer to the remote server. The first parameter is the form's input name and the second index can be either "name", "type", "size", "tmp_name" or "error". Like this:

$_FILES["file"]["name"] - the name of the uploaded file $_FILES["file"]["type"] - the type of the uploaded file $_FILES["file"]["size"] - the size in bytes of the uploaded file $_FILES["file"]["tmp_name"] - the name of the temporary copy of the file stored on the server $_FILES["file"]["error"] - the error code resulting from the file upload

This is a very simple way of uploading files. For security reasons, you should add restrictions on what the user is allowed to upload. Restrictions on Upload In this script we add some restrictions to the file upload. The user may only upload .gif or .jpeg files and the file size must be under 20 kb:

PAGE 115 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; } } else { echo "Invalid file"; } ?> Note: For IE to recognize jpg files the type must be pjpeg, for FireFox it must be jpeg. Saving the Uploaded File The examples above create a temporary copy of the uploaded files in the PHP temp folder on the server. The temporary copied files disappears when the script ends. To store the uploaded file we need to copy it to a different location:

PAGE 116 OF 185!

PHP PROGRAMMING !

<?php if ((($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg")) && ($_FILES["file"]["size"] < 20000)) { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?> The script above checks if the file already exists, if it does not, it copies the file to the specified folder. cookie is often used to identify a user.

PAGE 117 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Cookies
What is a Cookie? A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With PHP, you can both create and retrieve cookie values. How to Create a Cookie? The setcookie() function is used to set a cookie. Note: The setcookie() function must appear BEFORE the <html> tag. Syntax setcookie(name, value, expire, path, domain);

Example 1 In the example below, we will create a cookie named "user" and assign the value "Alex Porter" to it. We also specify that the cookie should expire after one hour: <?php setcookie("user", "Alex Porter", time()+3600); ?> <html> ..... Note: The value of the cookie is automatically URLencoded when sending the cookie, and automatically decoded when received (to prevent URLencoding, use setrawcookie() instead). Example 2 You can also set the expiration time of the cookie in another way. It may be easier than using seconds. <?php $expire=time()+60*60*24*30; setcookie("user", "Alex Porter", $expire); ?> <html> ..... In the example above the expiration time is set to a month (60 sec * 60 min * 24 hours * 30 days). How to Retrieve a Cookie Value? The PHP $_COOKIE variable is used to retrieve a cookie value. In the example below, we retrieve the value of the cookie named "user" and display it on a page:

PAGE 118 OF 185!

PHP PROGRAMMING !

<?php // Print a cookie echo $_COOKIE["user"]; // A way to view all cookies print_r($_COOKIE); ?> In the following example we use the isset() function to find out if a cookie has been set: <html> <body> <?php if (isset($_COOKIE["user"])) echo "Welcome " . $_COOKIE["user"] . "!<br />"; else echo "Welcome guest!<br />"; ?> </body> </html>

How to Delete a Cookie? When deleting a cookie you should assure that the expiration date is in the past. Delete example: <?php // set the expiration date to one hour ago setcookie("user", "", time()-3600); ?>

What if a Browser Does NOT Support Cookies? If your application deals with browsers that do not support cookies, you will have to use other methods to pass information from one page to another in your application. One method is to pass the data through forms (forms and user input are described earlier in this tutorial). The form below passes the user input to "welcome.php" when the user clicks on the "Submit" button: <html> <body> <form action="welcome.php" method="post"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> Retrieve the values in the "welcome.php" file like this:
PAGE 119 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<html> <body> Welcome <?php echo $_POST["name"]; ?>.<br /> You are <?php echo $_POST["age"]; ?> years old. </body> </html> The default error handling in PHP is very simple. An error message with filename, line number and a message describing the error is sent to the browser. PHP Error Handling When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. This tutorial contains some of the most common error checking methods in PHP. We will show different error handling methods:

Simple "die()" statements Custom errors and error triggers Error reporting

Basic Error Handling: Using the die() function The first example shows a simple script that opens a text file: <?php $file=fopen("welcome.txt","r"); ?> If the file does not exist you might get an error like this: Warning: fopen(welcome.txt) [function.fopen]: failed to open stream: No such file or directory in C:\webfolder\test.php on line 2 To avoid that the user gets an error message like the one above, we test if the file exist before we try to access it: <?php if(!file_exists("welcome.txt")) { die("File not found"); } else { $file=fopen("welcome.txt","r"); } ?> Now if the file does not exist you get an error like this:
PAGE 120 OF 185! !

PHP PROGRAMMING !

File not found The code above is more efficient than the earlier code, because it uses a simple error handling mechanism to stop the script after the error. However, simply stopping the script is not always the right way to go. Let's take a look at alternative PHP functions for handling errors.

PAGE 121 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

MYSQL
MySQL, pronounced either "My S-Q-L" or "My Sequel," is an open source relational database management system.It is used to manage or store data .datais stored in form of tables /relations.and put our all tables in our database.we can create our databases and can store any data.for eg.we create database for our company.we want to manage data realted to employees and our customers.we can create database like com and further create tables to mange our data.in above case as we can create two tables.one is used to manage records of employees working in the company and second for details of our customers . It is based on the structure query language (SQL), which is used for adding, removing, and modifying information in the database. Standard SQL commands, such as ADD, DROP, INSERT, and UPDATE can be used with MySQL. MySQL can be used for a variety of applications, but is most commonly found on Web servers. A website that uses MySQL may include Web pages that access information from a database. These pages are often referred to as "dynamic," meaning the content of each page is generated from a database as the page loads. Websites that use dynamic Web pages are often referred to as database-driven websites. Many database-driven websites that use MySQL also use a Web scripting language like PHP to access information from the database. MySQL commands can be incorporated into the PHP code, allowing part or all of a Web page to be generated from database information. Because both MySQL and PHP are both open source (meaning they are free to download and use), the PHP/MySQL combination has become a popular choice for database-driven websites.

Creating Your First Database


For all of our beginning examples we will be using the following information:

Server - localhost Database - test Table - example Username - admin Password - 1admin

The server is the name of the server we want to connect to. Because all of our scripts are going to be placed on the server where MySQL is located the correct address is localhost. If the MySQL server was on a different machine from where the script was running, then you would need to enter the correct url (ask your web host for specifics on this).

MySQL localhost
When the PHP script and MySQL are on the same machine, you can use localhost as the address you wish to connect to. localhost is a shortcut to just have the machine connect to itself. If your MySQL service is running at a separate location you will need to insert the IP address or URL in place of localhost. Please contact your web host for more details if localhost does not work. PHP & MySQL Code:
PAGE 122 OF 185! !

PHP PROGRAMMING !

<?php mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); echo "Connected to MySQL<br />"; ?> The mysql_connect function takes three arguments. Server, username, and password. In our example above these arguments were: Server localhost Username admin Password - 1admin

Choosing the Working Database


After establishing a MySQL connection with the code above, you then need to choose which database you will be using with this connection. This is done with the mysql_select_db function. PHP & MySQL Code: <?php mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("test") or die(mysql_error()); echo "Connected to Database"; ?> MySQL Tables
The columns specify what the data is going to be, while the rows contain the actual data. Below is how you could imagine a MySQL table. (C = Column, R = Row)

R1 R2 R3 R4

C1 (Name) R1 C1 (Sudhanshu) R2 C1 (Vivek) R3 C1 (Harpreet) R4 C1 (Jai)

C2 (Age) R1 C2 (21) R2 C2 (27) R3 C2 (6) R4 C2 (35)

C3 (Weight) R1 C3 (120) R2 C3 (400) R3 C3 (35) R4 C3 (160)

We added the row and column number (R# C#) so that you can see that a row is side-to-side, while a column is up-to-down. In a real MySQL table only the value would be stored, not the R# and C#! This table has three categories, or "columns", of data: Name, Age, and Weight. This table has four entries, or in other words, four rows. Create Table MySQL MySQL Code: "CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id),
PAGE 123 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

name VARCHAR(30), age INT)" ;

'id INT NOT NULL AUTO_INCREMENT'


Here we create a column "id" that will automatically increment each time a new entry is added to the table. This will result in the first row in the table having an id = 1, the second row id = 2, the third row id = 3, and so on. The column "id" is not something that we need to worry about after we create this table, as it is all automatically calculated within MySQL. Reserved MySQL Keywords: Here are a few quick definitions of the reserved words used in this line of code:

INT - This stands for integer or whole number. 'id' has been defined to be an integer. NOT NULL - These are actually two keywords, but they combine together to say that this column cannot be null. An entry is NOT NULL only if it has some value, while something with no value is NULL. AUTO_INCREMENT - Each time a new entry is added the value will be incremented by 1.

'PRIMARY KEY (id)' PRIMARY KEY is used as a unique identifier for the rows. Here we have made "id" the PRIMARY KEY for this table. This means that no two ids can be the same, or else we will run into trouble. This is why we made "id" an auto-incrementing counter in the previous line of code. 'name VARCHAR(30),' Here we make a new column with the name "name"! VARCHAR stands for "variable character". "Character" means that you can put in any kind of typed information in this column (letters, numbers, symbols, etc). It's "variable" because it can adjust its size to store as little as 0 characters and up to a specified maximum number of characters. We will most likely only be using this name column to store characters (A-Z, a-z). The number inside the parentheses sets the maximum number of characters. In this case, the max is 30. 'age INT,' Our third and final column is age, which stores an integer. Notice that there are no parentheses following "INT". MySQL already knows what to do with an integer. The possible integer values that can be stored in an "INT" are -2,147,483,648 to 2,147,483,647, which is more than enough to store someone's age! 'or die(mysql_error());' This will print out an error if there is a problem in the table creation process.

Mysql divided into Two Parts


1. Data Manipulation Language (DML) Data Manipulation Language (DML) statements are used for managing data within schema objects.

SELECT - Retrieve data from the a database


!

PAGE 124 OF 185!

PHP PROGRAMMING !

INSERT - Insert data into a table UPDATE - Update existing data within a table DELETE - Deletes all records from a table, the space for the records remain Data Definition Language (DDL)

2.

Data Definition Language (DDL) statements are used to define the database structure or schema.

CREATE - To create objects in the database ALTER - Alters the structure of the database DROP - Delete objects from the database

First Query we Are using is INSERT


In the insert query we insert the values into the database.The example is as following:-

Inserting Data Into Your Table PHP & MySQL Code: <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Insert a row of information into the table "example" mysql_query("INSERT INTO example (name, age) VALUES('Sudhanshu', '23' ) ") or die(mysql_error()); mysql_query("INSERT INTO example (name, age) VALUES('Mann', '21' ) ") or die(mysql_error()); mysql_query("INSERT INTO example (name, age) VALUES('Purnima', '15' ) ") or die(mysql_error()); echo "Data Inserted!"; ?> We Can Also insert values to Database with the help of Forms. First You have to create a form as follow:<form action="insert.php" method="post"> <input type="text" name="a" />
PAGE 125 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

<input type="text" name="b" /> <input type="submit" /> </form> After creating Form you have to insert the form values to the database with the help of the name you have given to <input type= text>. <?php mysql_connect('localhost','root',''); mysql_select_db('database_name'); $a = mysql_query("INSERT INTO table_name(tablefields) VALUES ('$_POST[a]','$_POST[c]')"); echo "Values Inserted"; ?>

Retrieving Data With PHP & MySQL Using MySQL SELECT & FROM
In the select query we used to get data from the database and show that particular result in the browser.Example:PHP & MySQL Code: <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry echo $row['database_fields_name']; ?> '$result = mysql_query("SELECT * FROM example")' When you perform a SELECT query on the database it will return a MySQL Resource that holds everything from your MySQL table, "example". We want to use this Resource in our PHP code, so we need to store it in a variable, $result. 'SELECT * FROM example' "Select every entry from the table example". The asterisk is the wild card in MySQL which just tells MySQL to include every single column for that table.
PAGE 126 OF 185! !

PHP PROGRAMMING !

'$row = mysql_fetch_array( $result );' $result is now a MySQL Resource containing data from your MySQL table, "example". Data is being stored in $result, but it is not yet visible to visitors of your website. When we pass $result into the mysql_fetch_array function -- mysql_fetch_array($result) -- an associative array (name, age) is returned. In our MySQL table "example," there are only two fields that we care about: name and age. These names are the keys to extracting the data from our associative array. To get the name we use $row['name'] and to get the age we use $row['age']. PHP is case sensitive when you reference MySQL column names, so be sure to use capitalization in your PHP code that matches the MySQL column names! Getting a Row of Data using mysql_fetch_array mysql_fetch_array returns the first row in a MySQL Resource in the form of an associative array. The columns of the MySQL Result can be accessed by using the column names of the table. In our table example these are: name and age. Here is the code to print out the first MySQL Result row. PHP and MySQL Code: <?php // Make a MySQL Connection $query = "SELECT * FROM example"; $result = mysql_query($query) or die(mysql_error());

$row = mysql_fetch_array($result) or die(mysql_error()); echo $row['name']. " - ". $row['age']; ?> Display: Sudhanshu - 23 This is just what we expected would happen! Now, the cool thing about mysql_fetch_array is that you can use it again on the same MySQL Resource to return the second, third, fourth and so on rows. You can keep doing this until the MySQL Resource has reached the end (which would be three times in our example). Sounds like an awfully repetitive task. It would be nice if we could get all our results from a MySQL Resource in an easy to do script.

Fetch Array While Loop


As we have said, the mysql_fetch_array function returns an associative array, but it also returns FALSE if there are no more rows to return! Using a PHP While Loop we can use this information to our advantage. If we place the statement "$row = mysql_fetch_array()" as our while loop's conditional statement we will accomplish two things: 1. We will get a new row of MySQL information that we can print out each time the while loop checks its conditional statement.
PAGE 127 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

2. When there are no more rows the function will return FALSE causing the while loop to stop! Now that we know what we need to do and how to go about doing it, the code pretty much writes itself, so let's move on to the next lesson. Just kidding! Here is the code that will print out all the rows of our MySQL Resource. PHP and MySQL Code: <?php // Make a MySQL Connection $query = "SELECT * FROM example"; $result = mysql_query($query) or die(mysql_error());

while($row = mysql_fetch_array($result)){ echo $row['name']. " - ". $row['age']; echo "<br />"; } ?> Display: Sudhanshu - 23 Bhavya - 21 Purnima - 15 And there we have all the rows from our example table! You could apply this script to any MySQL table as long as you change both the table name in the query and the column names that we have in the associative array.

PHP & MySQL Code: <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT * FROM example") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Age</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['name'];
PAGE 128 OF 185! !

PHP PROGRAMMING !

echo "</td><td>"; echo $row['age']; echo "</td></tr>"; } echo "</table>"; ?> '$result = mysql_query...' When you select items from a database using mysql_query, the data is returned as a MySQL result. Since we want to use this data in our table we need to store it in a variable. $result now holds the result from our mysql_query. 'SELECT * FROM example' In English, this line of code reads "Select everything from the table example". The asterisk is the wild card in MySQL which just tells MySQL to retrieve every single field from the table. 'while($row = mysql_fetch_array( $result )' The mysql_fetch_array function gets the next-in-line associative array from a MySQL result. By putting it in a while loop it will continue to fetch the next array until there is no next array to fetch. This function can be called as many times as you want, but it will return FALSE when the last associative array has already been returned. By placing this function within the conditional statement of the while loop, we can kill two birds with one stones. 1. We can retrieve the next associative array from our MySQL Resource, $result, so that we can print out the name and age of that person. 2. We can tell the while loop to stop printingn out information when the MySQL Resource has returned the last array, as False is returned when it reaches the end and this will cause the while loop to halt. In our MySQL table "example" there are only two fields that we care about: name and age. These fields are the keys to extracting the data from our associative array. To get the name we use $row['name'] and to get the age we use $row['age'].

OTHER SELECT QUERIES WE USE IN MYSQL MySQL Where


WHERE is used in conjuction with a mathematical statement. In our example we will want to select all rows that have the string "Sandy Smith" in the "names" column (mathematically: {name column} = "Sandy Smith"). Here's how to do it. PHP & MySQL Code: <?php
PAGE 129 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

// Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Get a specific result from the "example" table $result = mysql_query("SELECT * FROM example WHERE name='Sandy Smith'") or die(mysql_error()); // get the first (and hopefully only) entry from the result $row = mysql_fetch_array( $result ); // Print out the contents of each row into a table echo $row['name']." - ".$row['age']; ?>

MySQL Wildcard Usage '%'


In MySQL there is a "wildcard" character '%' that can be used to search for partial matches in your database. The '%' tells MySQL to ignore the text that would normally appear in place of the wildcard. For example '2%' would match the following: 20, 25, 2000000, 2avkldj3jklsaf, and 2! On the other hand, '2%' would not match the following: 122, a20, and 32.

MySQL Query WHERE With Wildcard


To solve our problem from before, selecting everyone who is their 20's from or MySQL table, we can utilize wildcards to pick out all strings starting with a 2. PHP & MySQL Code: <?php // Connect to MySQL // Insert a row of information into the table "example" $result = mysql_query("SELECT * FROM example WHERE age LIKE '2%' ") or die(mysql_error()); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row echo $row['name']." - ".$row['age']. "<br />"; } ?>

MySQL Order By
Ordering is also used quite frequently to add additional functionality to webpages that use any type of column layout. For example, some forums let you sort by date, thread title, post count, view count, and more.
PAGE 130 OF 185! !

PHP PROGRAMMING !

Sorting a MySQL Query - ORDER BY


Let's use the same query we had in MySQL Select and modify it to ORDER BY the person's age. The code from MySQL Select looked like... PHP & MySQL Code: <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT * FROM example") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Age</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['name']; echo "</td><td>"; echo $row['age']; echo "</td></tr>"; } echo "</table>"; ?> PHP & MySQL Code: <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Get all the data from the "example" table $result = mysql_query("SELECT * FROM example ORDER BY age") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th>Name</th> <th>Age</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table
PAGE 131 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

echo "<tr><td>"; echo $row['name']; echo "</td><td>"; echo $row['age']; echo "</td></tr>"; } echo "</table>"; ?>

MySQL Join Table Setup


We like to show examples and code before we explain anything in detail, so here is how you would combine two tables into one using MySQL. The two tables we will be using relate to a families eating habits. family Table: Position Dad Mom Daughter Dog Age 41 45 17

food Table: Meal Position Steak Dad Salad Mom Spinach Soup Tacos Dad The important thing to note here is that the column Position contains information that can tie these two tables together. In the "family" table, the Position column contains all the members of the family and their respective ages. In the "food" table the Position column contains the family member who enjoys that dish. It's only through a shared column relationship such as this that tables can be joined together, so remember this when creating tables you wish to have interact with each other.

MySQL Join Simple Example


PHP and MySQL Code: <?php // Make a MySQL Connection // Construct our join query $query = "SELECT family.Position, food.Meal ". "FROM family, food ".
PAGE 132 OF 185! !

PHP PROGRAMMING !

"WHERE family.Position = food.Position"; $result = mysql_query($query) or die(mysql_error());

// Print out the contents of each row into a table while($row = mysql_fetch_array($result)){ echo $row['Position']. " - ". $row['Meal']; echo "<br />"; } ?> The statement "WHERE family.Position = food.Position" will restrict the results to the rows where the Position exists in both the "family" and "food" tables. Display: Dad - Steak Mom - Salad Dad - Tacos Those are the results of our PHP script. Let's analyze the tables to make sure we agree with these results. Compare the Tables: Position Dad Mom Daughter Dog Age 41 45 17 Position Dad Mom Dad

Meal Steak Salad Spinach Soup Tacos

MySQL LEFT JOIN Explanation


This extra consideration to the left table can be thought of as special kind of preservation. Each item in the left table will show up in a MySQL result, even if there isn't a match with the other table that it is being joined to.

MySQL Join and LEFT JOIN Differences


Here are the tables we used in the previous Mysql Joins lesson. MySQL family and food Tables: Position Age
PAGE 133 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Dad 41 Mom 45 Daughter 17 Dog Meal Position Steak Dad Salad Mom Spinach Soup Tacos Dad We executed a simple query that selected all meals that were liked by a family member with this simple join query: Simplified MySQL Query: SELECT food.Meal, family.Position FROM family, food WHERE food.Position = family.Position Result: Dad - Steak Mom - Salad Dad - Tacos When we decide to use a LEFT JOIN in the query instead, all the family members be listed, even if they do not have a favorite dish in our food table. This is because a left join will preserve the records of the "left" table.

MySQL LEFT JOIN Example


The code below is the exact same as the code in the previous lesson, except the LEFT JOIN has now been added to the query. Let's see if the results are what we expected. PHP and MySQL Code: <?php // Make a MySQL Connection // Construct our join query $query = "SELECT family.Position, food.Meal ". "FROM family LEFT JOIN food ". "ON family.Position = food.Position"; $result = mysql_query($query) or die(mysql_error());

// Print out the contents of each row into a table while($row = mysql_fetch_array($result)){
PAGE 134 OF 185! !

PHP PROGRAMMING !

echo $row['Position']. " - ". $row['Meal']; echo "<br />"; } ?> Display: Dad - Steak Dad - Tacos Mom - Salad Daughter Dog -

MySQL Update MySQL Update Example


MySQL commands like UPDATE, SET, and WHERE.

UPDATE - Performs an update MySQL query SET - The new values to be placed into the table follow SET WHERE - Limits which rows are affected

PHP & MySQL Code: <?php // Connect to MySQL // Get Sandy's record from the "example" table $result = mysql_query("UPDATE example SET age='22' WHERE age='21'") or die(mysql_error());

$result = mysql_query("SELECT * FROM example WHERE age='22'") or die(mysql_error()); // get the first (and hopefully only) entry from the result $row = mysql_fetch_array( $result ); echo $row['name']." - ".$row['age']. "<br />"; ?> Display: Sandy Smith - 22

MySQL DELETE Example


PHP & MySQL Code: <?php // Connect to MySQL
PAGE 135 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

// Delete Bobby from the "example" MySQL table mysql_query("DELETE FROM example WHERE age='15'") or die(mysql_error()); ?> It is important to note that this query would have deleted ALL records that had an age of 15. Since Bobby was the only 15 year old this was not a problem.

MySQL Aggregate Functions


COUNT() Products Table: id name type price 123451 Park's Great Hits Music 19.99 123452 Silly Puddy Toy 3.99 123453 Playstation Toy 89.95 123454 Men's T-Shirt Clothing 32.50 123455 Blouse Clothing 34.97 123456 Electronica 2002 Music 3.99 123457 Country Tunes Music 21.55 123458 Watermelon Food 8.73 The COUNT function is an aggregate function that simply counts all the items that are in a group. The "products" table that is displayed above has several products of various types. One use of COUNT might be to find out how many items of each type there are in the table. Just as we did in the aggregate introduction lesson, we are going to GROUP BY type to create four groups: Music, Toy, Clothing and Food. For a slight change of pace, let's count the name column to find how many products there are per type. PHP and MySQL Code: <?php // Make a MySQL Connection $query = "SELECT type, COUNT(name) FROM products GROUP BY type"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "There are ". $row['COUNT(name)'] ." ". $row['type'] ." items."; echo "<br />"; } ?>
PAGE 136 OF 185! !

PHP PROGRAMMING !

Display: There are 2 Clothing items. There are 1 Food items. There are 3 Music items. There are 2 Toy items. SUM() Products Table: id 123451 123452 123453 123454 123455 123456 123457 123458 name Park's Great Hits Silly Puddy Playstation Men's T-Shirt Blouse Electronica 2002 Country Tunes Watermelon type Music Toy Toy Clothing Clothing Music Music Food price 19.99 3.99 89.95 32.50 34.97 3.99 21.55 8.73

MySQL SUM - Totaling Groups


SUM is an aggregate function that totals a specific column for a group. The "products" table that is displayed above has several products of various types. One use of SUM might be to find the total of all the items' price for each product type. Just as we did in the aggregate introduction lesson, we are going to apply the aggregate function to price and GROUP BY type to create four groups: Music, Toy, Clothing and Food. PHP and MySQL Code: <?php // Make a MySQL Connection $query = "SELECT type, SUM(price) FROM products GROUP BY type"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "Total ". $row['type']. " = $". $row['SUM(price)']; echo "<br />"; } ?> Display: Total Clothing = $67.47 Total Food = $8.73
PAGE 137 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Total Music = $45.53 Total Toy = $93.94

AVG()
Products Table: id 123451 123452 123453 123454 123455 123456 123457 123458 name Park's Great Hits Silly Puddy Playstation Men's T-Shirt Blouse Electronica 2002 Country Tunes Watermelon type Music Toy Toy Clothing Clothing Music Music Food price 19.99 3.99 89.95 32.50 34.97 3.99 21.55 8.73

MySQL Average - Finding a Middle Ground


The AVG function returns the average value for the specified column of a group. Our imaginary customers have been complaining recently that our prices are too high, so we would like to find out the average price of each product type to see if this is in fact the truth. To find out this metric we are going to apply the aggregate function to the price and GROUP BY type to create four price groups: Music, Toy, Clothing and Food. PHP and MySQL Code: <?php // Make a MySQL Connection $query = "SELECT type, AVG(price) FROM products GROUP BY type"; $result = mysql_query($query) or die(mysql_error()); // Print out result while($row = mysql_fetch_array($result)){ echo "The average price of ". $row['type']. " is $".$row['AVG(price)']; echo "<br />"; } ?> Display: The average price of Clothing is $33.735000 The average price of Food is $8.730000 The average price of Music is $15.176667 The average price of Toy is $46.970000
PAGE 138 OF 185! !

PHP PROGRAMMING !

MySQL - SQL Injection Prevention


What is SQL Injection SQL injection refers to the act of someone inserting a MySQL statement to be run on your database without your knowledge. Injection usually occurs when you ask a user for input, like their name, and instead of a name they give you a MySQL statement that you will unknowingly run on your database. SQL Injection Example Below is a sample string that has been gathered from a normal user and a bad user trying to use SQL Injection. We asked the users for their login, which will be used to run a SELECT statement to get their information. MySQL & PHP Code: // a good user's name $name = "timmy"; $query = "SELECT * FROM customers WHERE username = '$name'"; echo "Normal: " . $query . "<br />"; // user input that uses SQL Injection $name_bad = "' OR 1'"; // our MySQL query builder, however, not a very safe one $query_bad = "SELECT * FROM customers WHERE username = '$name_bad'"; // display what the new query will look like, with injection echo "Injection: " . $query_bad; Display: Normal: SELECT * FROM customers WHERE username = 'timmy' Injection: SELECT * FROM customers WHERE username = '' OR 1'' The normal query is no problem, as our MySQL statement will just select everything from customers that has a username equal to timmy. However, the injection attack has actually made our query behave differently than we intended. By using a single quote (') they have ended the string part of our MySQL query

username = ' ' username = ' ' OR 1

and then added on to our WHERE statement with an OR clause of 1 (always true).

This OR clause of 1 will always be true and so every single entry in the "customers" table would be selected by this statement! More Serious SQL Injection Attacks
PAGE 139 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Although the above example displayed a situation where an attacker could possibly get access to a lot of information they shouldn't have, the attacks can be a lot worse. For example an attacker could empty out a table by executing a DELETE statement. MySQL & PHP Code: $name_evil = "'; DELETE FROM customers WHERE 1 or username = '"; // our MySQL query builder really should check for injection $query_evil = "SELECT * FROM customers WHERE username = '$name_evil'"; // the new evil injection query would include a DELETE statement echo "Injection: " . $query_evil; Display: SELECT * FROM customers WHERE username = ' '; DELETE FROM customers WHERE 1 or username = ' ' If you were run this query, then the injected DELETE statement would completely empty your "customers" table. Now that you know this is a problem, how can you prevent it?

Injection Prevention - mysql_real_escape_string()


Lucky for you, this problem has been known for a while and PHP has a specially-made function to prevent these attacks. All you need to do is use the mouthful of a function mysql_real_escape_string. What mysql_real_escape_string does is take a string that is going to be used in a MySQL query and return the same string with all SQL Injection attempts safely escaped. Basically, it will replace those troublesome quotes(') a user might enter with a MySQL-safe substitute, an escaped quote \'. Lets try out this function on our two previous injection attacks and see how it works. MySQL & PHP Code: //NOTE: you must be connected to the database to use this function! // connect to MySQL $name_bad = "' OR 1'"; $name_bad = mysql_real_escape_string($name_bad); $query_bad = "SELECT * FROM customers WHERE username = '$name_bad'"; echo "Escaped Bad Injection: <br />" . $query_bad . "<br />";

$name_evil = "'; DELETE FROM customers WHERE 1 or username = '"; $name_evil = mysql_real_escape_string($name_evil); $query_evil = "SELECT * FROM customers WHERE username = '$name_evil'"; echo "Escaped Evil Injection: <br />" . $query_evil; Display:
PAGE 140 OF 185! !

PHP PROGRAMMING !

Escaped Bad Injection: SELECT * FROM customers WHERE username = '\' OR 1\'' Escaped Evil Injection: SELECT * FROM customers WHERE username = '\'; DELETE FROM customers WHERE 1 or username = \'' Notice that those evil quotes have been escaped with a backslash \, preventing the injection attack. Now all these queries will do is try to find a username that is just completely ridiculous:

Bad: \' OR 1\' Evil: \'; DELETE FROM customers WHERE 1 or username = \'

And I don't think we have to worry about those silly usernames getting access to our MySQL database. So please do use the handy mysql_real_escape_string() function to help prevent SQL Injection attacks on your websites

PAGE 141 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

JQUERY
The jQuery library can be added to a web page with a single line of markup.

What is jQuery?
jQuery is a library of JavaScript Functions. jQuery is a lightweight "write less, do more" JavaScript library. The jQuery library contains the following features: HTML element selections HTML element manipulation CSS manipulation HTML event functions JavaScript Effects and animations HTML DOM traversal and modification AJAX Utilities Adding the jQuery Library to Your Pages The jQuery library is stored as a single JavaScript file, containing all the jQuery methods. It can be added to a web page with the following mark-up: <head> <script type="text/javascript" src="jquery.js"></script> </head> Please note that the <script> tag should be inside the page's <head> section. Basic jQuery Example The following example demonstrates the jQuery hide() method, hiding all <p> elements in an HTML document.

PAGE 142 OF 185!

PHP PROGRAMMING !

Example <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Click me</button> </body> </html>Try it yourself

Downloading jQuery
Two versions of jQuery are available for downloading: one minified and one uncompressed (for debugging or reading). Both versions can be downloaded from HYPERLINK "http://docs.jquery.com/ Alternatives to Downloading If you don't want to store the jQuery library on your own computer, you can use the hosted jQuery library from Google or Microsoft. Alternatives to Downloading If you don't want to store the jQuery library on your own computer, you can use the hosted jQuery library from Google or Microsoft. Google <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/ jquery.min.js"></script> </head> ry it yourself
PAGE 143 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Microsoft <head> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery/ jquery-1.4.2.min.js"></script> </head> rself With jQuery you select (query) HTML elements and perform "actions" on them.

jQuery Syntax Examples

jQuery Syntax The jQuery syntax is tailor made for selecting HTML elements and perform some action on the element(s). Basic syntax is: $(selector).action() A dollar sign to define jQuery A (selector) to "query (or find)" HTML elements A jQuery action() to be performed on the element(s) Examples: $(this).hide() - hides current element $("p").hide() - hides all paragraphs $("p.test").hide() - hides all paragraphs with class="test" $("#test").hide() - hides the element with id="test" jQuery uses a combination of XPath and CSS selector syntax. You will learn more about the selector syntax in the next chapter of this tutorial.

The Document Ready Function You might have noticed that all jQuery methods, in our examples, are inside a document.ready() function:

PAGE 144 OF 185!

PHP PROGRAMMING !

$(document).ready(function(){ // jQuery functions go here... }); This is to prevent any jQuery code from running before the document is finished loading (is ready). Here are some examples of actions that can fail if functions are run before the document is fully loaded: Trying to hide an element that doesn't exist Trying to get the size of an image that is not loaded

jQuery Selectors
It is a key point to learn how jQuery selects exactly the elements you want to apply an effect to. jQuery selectors allow you to select HTML elements (or groups of elements) by element name, attribute name or by content.

jQuery Element Selectors


jQuery uses CSS selectors to select HTML elements. $("p") selects all <p> elements. $("p.intro") selects all <p> elements with class="intro". $("p#demo") selects all <p> elements with id="demo".

jQuery Attribute Selectors


jQuery uses XPath expressions to select elements with given attributes. $("[href]") select all elements with an href attribute. $("[href='#']") select all elements with an href value equal to "#". $("[href!='#']") select all elements with an href attribute NOT equal to "#". $("[href$='.jpg']") select all elements with an href attribute that ends with ".jpg".

jQuery CSS Selectors


jQuery CSS selectors can be used to change CSS properties for HTML elements. The following example changes the background-color of all p elements to yellow: Example $("p").css("background-color","yellow"); ry it yourself
PAGE 145 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Some More Examples


Syntax $(this) $("p") $("p.intro") $("p#intro") $("p#intro:first") $(".intro") $("#intro") $("ul li:first") $("[href$='.jpg']") $("div#intro .head") Description Current HTML element All <p> elements All <p> elements with class="intro" All <p> elements with id="intro" The first <p> element with id="intro" All elements with class="intro" The first element with id="intro" The first <li> element of each <ul> All elements with an href attribute that ends with ".jpg" All elements with class="head" inside a <div> element with id="intro"

jQuery Event Functions


The jQuery event handling methods are core functions in jQuery. Event handlers are method that are called when "something happens" in HTML. The term "triggered (or "fired") by an event" is often used. It is common to put jQuery code into event handler methods in the <head> section:

PAGE 146 OF 185!

PHP PROGRAMMING !

Example <html> <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").hide(); }); }); </script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Click me</button> </body> </html>Try it yourself In the example above, a function is called when the click event for the button is triggered: $("button").click(function() {..some code... } ) The method hides all <p> elements: $("p").hide(); Functions In a Separate File If your website contains a lot of pages, and you want your jQuery functions to be easy to maintain, put your jQuery functions in a separate .js file. When we demonstrate jQuery here, the functions are added directly into the <head> section, However, sometimes it is preferable to place them in a separate file, like this (refer to the file with the src attribute): Example <head> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="my_jquery_functions.js"></script> </head>

PAGE 147 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

jQuery Name Conflicts


jQuery uses the $ sign as a shortcut for jQuery. Some other JavaScript libraries also use the dollar sign for their functions. The jQuery noConflict() method specifies a custom name (like jq), instead of using the dollar sign. jQuery Events Here are some examples of event methods in jQuery: Event Method $(document).ready(function) Description Binds a function to the ready event of a document (when the document is finished loading) Triggers, or binds a function to the click event of selected elements Triggers, or binds a function to the double click event of selected elements Triggers, or binds a function to the focus event of selected elements Triggers, or binds a function to the mouseover event of selected elements

$(selector).click(function) $(selector).dblclick(function) $(selector).focus(function) $(selector).mouseover(function)

jQuery Hide and Show


With jQuery, you can hide and show HTML elements with the hide() and show() methods: Example $("#hide").click(function(){ $("p").hide(); }); $("#show").click(function(){ $("p").show(); });Try it yourself Both hide() and show() can take the two optional parameters: speed and callback. Syntax: $(selector).hide(speed,callback) $(selector).show(speed,callback) The speed parameter specifies the speed of the hiding/showing, and can take the following values: "slow", "fast", "normal", or milliseconds:

PAGE 148 OF 185!

PHP PROGRAMMING !

Example $("button").click(function(){ $("p").hide(1000); }); Try it yourself


The callback parameter is the name of a function to be executed after the hide (or show) function completes. You will learn more about the callback parameter in the next chapter of this tutorial.

jQuery Toggle
The jQuery toggle() method toggles the visibility of HTML elements using the show() or hide() methods. Shown elements are hidden and hidden elements are shown. Syntax: $(selector).toggle(speed,callback) The speed parameter can take the following values: "slow", "fast", "normal", or milliseconds. Example $("button").click(function(){ $("p").toggle(); }); Try it yourself The callback parameter is the name of a function to be executed after the hide (or show) method completes. jQuery Slide - slideDown, slideUp, slideToggle The jQuery slide methods gradually change the height for selected elements. jQuery has the following slide methods: $(selector).slideDown(speed,callback) $(selector).slideUp(speed,callback) $(selector).slideToggle(speed,callback) The speed parameter can take the following values: "slow", "fast", "normal", or milliseconds. The callback parameter is the name of a function to be executed after the function completes. slideDown() Example $(".flip").click(function(){ $(".panel").slideDown(); }); Try it yourself
PAGE 149 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

slideUp() Example $(".flip").click(function(){ $(".panel").slideUp() })

Try it yourself slideToggle() Example $(".flip").click(function(){ $(".panel").slideToggle(); });Try it yourself

jQuery Fade - fadeIn, fadeOut, fadeTo The jQuery fade methods gradually change the opacity for selected elements. jQuery has the following fade methods: $(selector).fadeIn(speed,callback) $(selector).fadeOut(speed,callback) $(selector).fadeTo(speed,opacity,callback) The speed parameter can take the following values: "slow", "fast", "normal", or milliseconds. The opacity parameter in the fadeTo() method allows fading to a given opacity. The callback parameter is the name of a function to be executed after the function completes. fadeTo() Example $("button").click(function(){ $("div").fadeTo("slow",0.25); }); Try it yourself fadeOut() Example $("button").click(function(){ $("div").fadeOut(4000); }); Try it yourself

jQuery Custom Animations


The syntax of jQuery's method for making custom animations is:
PAGE 150 OF 185! !

PHP PROGRAMMING !

$(selector).animate({params},[duration],[easing],[callback]) The key parameter is params. It defines the CSS properties that will be animated. Many properties can be animated at the same time:

animate({width:"70%",opacity:0.4,marginLeft:"0.6in",fontSize:"3em"});
The second parameter is duration. It specifies the speed of the animation. Possible values are "fast", "slow", "normal", or milliseconds. Example 1 <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("div").animate({height:300},"slow"); $("div").animate({width:300},"slow"); $("div").animate({height:100},"slow"); $("div").animate({width:100},"slow"); }); }); </script> Try it yourself

jQuery Effects
Here are some examples of effect functions in jQuery: Function $(selector).hide() $(selector).show() $(selector).toggle() $(selector).slideDown() $(selector).slideUp() $(selector).slideToggle() $(selector).fadeIn() $(selector).fadeOut() $(selector).fadeTo() $(selector).animate() Description Hide selected elements Show selected elements Toggle (between hide and show) selected elements Slide-down (show) selected elements Slide-up (hide) selected elements Toggle slide-up and slide-down of selected elements Fade in selected elements Fade out selected elements Fade out selected elements to a given opacity Run a custom animation on selected elements

jQuery Callback Functions


PAGE 151 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

A callback function is executed after the current animation (effect) is finished. JavaScript statements are executed line by line. However, with animations, the next line of code can be run even though the animation is not finished. This can create errors. To prevent this, you can create a callback function. The callback function will not be called until after the animation is finished. jQuery Callback Example Typical syntax: $(selector).hide(speed,callback) The callback parameter is a function to be executed after the hide effect is completed: Example with Callback $("p").hide(1000,function(){ alert("The paragraph is now hidden"); }); Try it yourself Without a callback parameter, the alert box is displayed before the hide effect is completed: Example without Callback $("p").hide(1000); alert("The paragraph is now hidden");Try it yourself Changing HTML Content $(selector).html(content) The html() method changes the contents (innerHTML) of matching HTML elements. Example $("p").html("Netmax"); Adding HTML content $(selector).append(content) The append() method appends content to the inside of matching HTML elements. $(selector).prepend(content) The prepend() method "prepends" content to the inside of matching HTML elements. Example $("p").append(" Netmax"); $(selector).after(content) The after() method inserts HTML content after all matching elements.
PAGE 152 OF 185! !

PHP PROGRAMMING !

$(selector).before(content) The before() method inserts HTML content before all matching elements. Example $("p").after("Netmax");

jQuery HTML Manipulation Methods From This Page:

Function
$(selector).html(content) $(selector).append(content) $(selector).after(content) jQuery css() Method

Description
Changes the (inner) HTML of selected elements Appends content to the (inner) HTML of selected elements Adds HTML after selected elements

jQuery has one important method for CSS manipulation: css() The css() method has three different syntaxes, to perform different tasks. css(name) - Return CSS property value css(name,value) - Set CSS property and value css({properties}) - Set multiple CSS properties and values Return CSS Property Use css(name) to return the specified CSS property value of the FIRST matched element: Example $(this).css("background-color");

Set CSS Property and Value Use css(name,value) to set the specified CSS property for ALL matched elements: Example $("p").css("background-color","yellow"); Try it yourself

PAGE 153 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Set Multiple CSS Property/Value Pairs Use css({properties}) to set one or more CSS property/value pairs for the selected elements: jQuery height() and width() Methods jQuery has two important methods for size manipulation. height() width() Size Manipulation Examples The height() method sets the height of all matching elements: Example $("#div1").height("200px"); Try it yourself The width() method sets the width of all matching elements: Example $("#div2").width("300px");

jQuery CSS Methods From this Page:


CSS Properties $(selector).css(name) $(selector).css(name,value) $(selector).css({properties}) $(selector).height(value) $(selector).width(value) Description Get the style property value of the first matched element Set the value of one style property for matched elements Set multiple style properties for matched elements Set the height of matched elements Set the width of matched elements

PAGE 154 OF 185!

PHP PROGRAMMING !

WordPress is an open source blog publishing application powered by PHP and MySQL which can also be used for content management. It has many features including a workflow, a plug-in architecture and a templating system

Installation Process Working In wordpress ( Step by step) Installation Process On Wamp/ Xampp Server Step -1: GO TO THIS LINK http://www.wordpress.org/ Step -2: Now Download Wordpress ZIP file in 3.1 Or Now available any one Step -3: After this file copy on your Wamp/Xampp Server in WWW Directory Step-4: Extract this file Step-5: And now click on wamp server in localhost Step-6: Your installation process Start Step-7: 1st step now this Create a configuration file.( click on this button)

PAGE 155 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Step-8: 2nd step is Welcome section now this ( click on Lets Go Button)

Step-9: 3rd step Database, below you should enter your database connection details. If you're not sure about these, contact your host.

PAGE 156 OF 185!

PHP PROGRAMMING !

Step-10: Fill the all database information , but this information should be create phpmy admin Step-11: GO to Wamp server and click on phpmy admin. And create a database like this Suppose now create a database name is Netmax and click the create button.

PAGE 157 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Step -12: Again go to installation process , and fill database information like this

Step-13:

Step-14: Click on Run the install button

Step-15: Now see Welcome page and fill the all information

PAGE 158 OF 185!

PHP PROGRAMMING !

! Site title- Your Website Name ! Username- By default admin ! Password, twice your choice ! Your E-mail- your choice Step- 16: Click on this button

Step-17: See your success page

PAGE 159 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Step-18: click on Log In button Step:-19: Fill Username and Password like this
! Username : admin ! Password: admin

Step-20: See Admin Control Panel (Dashboard)

PAGE 160 OF 185!

PHP PROGRAMMING !

Step-21: Finish! Working on Wordpress Administration Panels The Administration Panel provides access to the control features of your WordPress installation.

PAGE 161 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Dashboard - Information Central


The Dashboard tells you about recent activity both at your site and in the WordPress community at large and provide access to updating WordPress, plugins, and themes. Dashboard The Dashboard Dashboard subPanel provides you a number of links to start writing Posts or Pages, statistics and links on the number of posts, pages, Categories, and Post Tags. A Recent Comments box shows the number of Comments awaiting moderation and a list of the recent Wordpress Tutorial comments. Configurable boxes of Incoming Links, and RSS feeds from the WordPress Blog, the Plugins blog, and Planet WordPress are also displayed. How to work DashboardQuick Process- this section easily any comment or any update Post by admin

! Title Comment or update title name write here ! Upload /insert Picture, Video ,Video, Media ! Content- Write full decription ! Tags like Where u publish this section ! After click on Publish Button ! And now see Your post . Go this link http://localhost/wordpress/ ! After see your Post . Right Now This section are theme information, post information e.t.c
PAGE 162 OF 185! !

PHP PROGRAMMING !

By default theme is Twenty Ten ? if change other theme-Now Download Theme wordress Site for Download theme " http://www.themebase.com/ " http://www.wordpress.com/ " http://www.Sitegaurd.com/ Updates The Dashboard Updates SubPanel gives you an easy method to update WordPress, plugins, and themes. Note not all hosts will allow the automatic update process to work successfully and will require you to manually upgrade by following the Upgrading WordPress instructions.

Posts Sub panel Posts Add New Categories Post Tags


This section Via the Posts Posts SubPanel you can select the Post or Posts you wish to edit, delete, or view. Multiple Posts can be selected for deletion and for editing. A powerful bulk edit feature allows you to change certains fields, en masse, for a group of Posts. A handy in-line edit tool, called Quick Edit, allows you to update many fields for an individual Post. Various search and filtering options allow you to find the Posts you want to edit or delete. Add New Post The most important part of WordPress, the Posts Add New SubPanel is where you write new
PAGE 163 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Posts. While you are writing those Posts, you can also create new Categories, new Tags, and new Custom Fields. In addition, any Media (pictures, video, recordings, files) can be uploaded and inserted into the Posts. Like this

! ! ! !

Enter title here: post Title After full description in post topic Now click on Publish button After we see your output page and see new post via admin

Note: This post are any name like where you see this post like which Categories, like uncategorized or any other ( if any other so click on add new Category) Categories Every Post in WordPress is filed under one or more Categories. Categories allow the classification of your Posts into groups and subgroups, thereby aiding viewers in the navigation and use of your site. Each Category may be assigned to a Category Parent so that you may set up a hierarchy within
PAGE 164 OF 185! !

PHP PROGRAMMING !

the category structure. Using automobiles as an example, a hierarchy might be Car->Ford>Mustang. In creating categories, recognize that each category name must be unique, regardles of hierarchy. When using the WordPress TwentyTen theme, Categories are shown in two different places on the blog's home page. First, the Categories are listed as links in the Category section of your sidebar, and second, all the Categories to which a given post belongs are displayed under that post. When someone viewing your blog clicks on one of those Category links, a archive page with all the Posts belonging to that Category will be displayed Like this click on Categories button

PAGE 165 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Post Tags Tags are the keywords you might assign to each post. Not to be confused with Categories, Tags have no hierarchy, meaning there's no relationship from one Tag to another. But like Categories, Tags provide another means to aid your readers in accessing information on your blog.
Like this Means Post tag ( post Title)

Click on add tag

Media - Add pictures and movies to your posts


PAGE 166 OF 185! !

PHP PROGRAMMING !

Media is the images, video, recordings, and files, you upload and use in your blog. Media is typically uploaded and inserted into the content when writing a Post or Page. Note that the Uploading Files section in the Settings Media SubPanel describes the location and structure of the upload directory. Library Add New Library The Media Library SubPanel allows you edit, delete or view Media previously uploaded to your blog. Multiple Media objects can be selected for deletion. Search and filtering ability is also provided to allow you to find the desired Media. Like this

Now click on add new after we add a new media file like video, audio e.t.c Add New Media The Media Add New SubPanel allows you to upload new media to later use with posts and pages. A Flash Uploader is provided and the ability to use a Browser Uploader is supplied if the Flash Uploader does not work.

! Like a add a image ! After u see this


PAGE 167 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Now fill description and titles name and save this media file Links SubPanels Links Add New Link Categories

The Links L SubPanel allows you to select the Links to edit or delete. Multiple Links can be
PAGE 168 OF 185! !

PHP PROGRAMMING !

selected for deletion. Various search and filtering options allow you to find the Links you want to edit or delete. Add New Link As you might expect from its name, the Links Add New SubPanel handles the creation of new links. Click on add new link like this

PAGE 169 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Fill all link information like


PAGE 170 OF 185! !

PHP PROGRAMMING !

! Link name ! Link address like http://www.wordpress/admin.php/ ! Description in link ! Set the categories where the link ! Target like link where to open blank- self e.t.c ! Link relationship by default none ! Advance if image address or rss address fil ! After click add link button on top side Link Categories Links, like Posts, can be categorized and categorizing Links aids your audience in navigation of your Links. But Link Categories, unlike post Categories, have no hierarchy (parent/child relationship). In creating categories, recognize that each Category name must be unique. The Links Link Categories SubPanel allows you to add, edit, and delete Link Categories. Multiple Link Categories can be selected for deletion. A search option allows you to find the Link Categories you want to edit or delete. Also remember Link Categories can be added when adding or editings Links. Like this

PAGE 171 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

PAGE 172 OF 185!

PHP PROGRAMMING !

Pages - Your Static Content


A Page is another tool to add content to a WordPress site and is often used to present "static" information about the site; Pages are typically "timeless" in nature. A good example of a Page is the information contained in "About" or "Contact" Pages. SubPanels Pages Add New Pages The Pages Pages SubPanel provides the necessary tools to edit, delete, and view existing Pages.. On this SubPanel you can select the Page to edit or delete. Multiple Pages can be selected for deletion and for editing. As with Posts, a powerful bulk edit tool allows certain fields to be edited for a whole group of Pages. A handy in-line edit tool, called Quick Edit, allows you to update many fields for an individual Page. Various search and filtering options allow you to find the Pages you want to edit or delete. Like this

Pages are often used to create a simple static page like about your site your contact or your services pages Now this images are shown in all pages in your site . Add New Page The Add New Page SubPanel allows you to create new Pages. Also see the Pages article for an in depth discussion. When click this link button like this u see,

PAGE 173 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

! Page title here ! And full description here and click on Publish button ! And after we see add a new page like about us on your web pages

Comments - Reader Feedback


Comments are a feature of blogs which allow readers to respond to Posts. Typically readers simply provide their own thoughts regarding the content of the post, but users may also provide links to other resources, generate discussion, or simply compliment the author for a well-written post. Comments can be controlled and regulated through the use of filters for language and content, and often times can be queued for approval before they are visible on the web site. This is useful in dealing with comment spam.

PAGE 174 OF 185!

PHP PROGRAMMING !

Appearance - Change the Look of your Blog


From the Presentation Administration Panel you can control how the content of your blog is displayed. WordPress allows you to easily style your site by either installing and activating new Themes or changing existing Themes. Themes Widgets Menus Background Header Editor Themes A Theme is the overall design of a site and encompasses color, graphics, and text. A Theme is sometimes called the skin. WordPress site-owners have available a long list of Themes to choose from in deciding what to present to their sites' viewers. visitors can select their own Theme.

Note :- Download wordpress theme zip file and extract the file and copy this file in wamp server in www directory in woedpress- folder- wp-content- theme copy here . Or when you click theme link now see

PAGE 175 OF 185!

NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Now click on install theme Click on upload link

Now search wordpress theme in zip file and install now. After successfully install a theme Widgets Widgets are gadgets or gizmos that allow you to add various pieces of information to your Theme's sidebar content. Widgets, for example, can be used to add Categories, Archives, Blogroll, Recent Posts, and Recent Comments to your sidebar. Like thisPAGE 176 OF 185! !

PHP PROGRAMMING !

This widgets are not working here. How to work? Now see each widgets like link, calendar, are show in how to work this widgets. Now this work are own try. Menus The Menus feature allows you to create a navigation menu of pages, categories, custom links, tags, etc. that is presented to your visitors. This option will only be present if the Theme author has configured the theme to allow this capability. For instance, the WordPress TwentyTen theme allows you to create the menu that is displayed in the lower part of the that theme's header. Now click on menu link You see this image

Now write a menu name and click create menu ! To create a custom menu, give it a name above and click Create Menu. Then choose items like pages, categories or custom links from the left column to add to this menu. ! After you have added your items, drag and drop to put them in the order you want. You can also click each item to reveal additional configuration options. ! When you have finished building your custom menu, make sure you click the Save Menu button. ! After you see your website page then add a new menu Background The Background feature allows you to manage the look and feel of background for your theme.
PAGE 177 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

This option will only be present if the Theme author has configured the theme to allow this capability. For instance, the WordPress TwentyTen theme allows you to set the background image or the background color.

! This section change the background theme in your site

Header The Header feature allows you to manage what image is displayed in a Theme's header. ! Click on header link now see

PAGE 178 OF 185!

PHP PROGRAMMING !

! 2 option chose 1st browse any other image or ! 2nd chose by default image ! Suppose u chose by default image any one like this.

! And click save link ! After you see webpage change your header image.

Theme Editor Use the Theme Editor to edit the various files that comprise your Themes. The Appearance
PAGE 179 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Editor SubPanel allows you to designate which theme you want to edit then displays the files in that theme. Each file (Template and CSS) in the theme can be edited in the large text box. Plugins The Plugins Installed SubPanel allows you to view the plugins you've downloaded and choose which plugins you want activated on your site. For information on downloading and installing plugins, see Managing Plugins. Add New Plugins The Plugins Add New SubPanel allows you to add new plugins. For information on downloading and installing plugins. Like this :-

! Upload a plug-in Plugin Editor Using the Plugins Editor SubPanel, you can modify the source code of all your plugins.

Users - Your Blogging Family


Every blog probably has at least two users: admin, the account initially set up by WordPress, and the user account you, as the author/owner of the blog, use to write posts. But maybe you want more; perhaps you want several authors for your blog. If you want a person to be able to post to your blog, that person must have access to a user account; typically, every person will have her or his own user account. SubPanels Users Add New
PAGE 180 OF 185! !

PHP PROGRAMMING !

Your Profile Users You can manage the accounts of all your site's users at the Users Users SubPanel. ! By default current user now admin ( this section all admin information )

! Fill all new user information and click add new user ! Benfit for new user like ! Change any information in website ! Post any comment any news using own username and password ! Means Any information like post are e.t.c change are post user ( now authority via ! admin section ) ! Admin and user use own id n password and change any content
PAGE 181 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

Your Profile The Users Your Profile SubPanel allows to change any information related to your user account. ! This section admin or user information like id password, name , nik name e.t.c

Tools - Managing your Blog


WordPress Tools provide you the ability to speed up WordPress for your local machine, import content from other sources, export your content, or to upgrade your WordPress software to a new release. SubPanels Tools Import Export Tools The Press This function allows quick posting and publishing through the use of a special web browser favourite. You can create a shortcut to allow use of "Press This" from the new post screen. You then activate the function when browsing by selecting the favorite from your web browser favorites list. The Tools SubPanel describes the Press This functions. Import WordPress supports the importing data from a number external sources. In many cases, posts, comments, pages, categories, tags, and users, can be imported. The Tools Import SubPanel list the software packages that WordPress can import and details what types of data from each of those platforms qualifies for import. Also see Importing Content for a more extensive list of import possibilites. Export WordPress Export will create an XML file for you to save to your computer. The format, which is called a WordPress eXtended RSS or WXR file, will contain your posts, comments, custom fields, categories, and tags. The Tools Export SubPanel guides you through the easy process of exporting your blog. Take note that the Exporting is a useful method to backup your WordPress data.

Settings - Configuration Settings


PAGE 182 OF 185! !

PHP PROGRAMMING !

SubPanels General Writing Reading Discussion Media Privacy Permalinks General The Settings General SubPanel is the default SubPanel in the Settings Administration Panel and controls some of the most basic configuration settings for your site: your site's title and location, who may register an account at your blog, and how dates and times are calculated and displayed.

After we change all setting and save this setting and refresh on your site and see new changes . ! Like your header theme line in ( Just another website) ! So this tagline are change here( like I hate your )
PAGE 183 OF 185! ! NETMAX TECHNOLOGIES

SUBJECT: HTML BASICS!

! And save it ! Now see Writing Using the Settings Writing SubPanel, you can control the interface with which you write new posts. These settings control the size of the 'post box' in the Write Post SubPanel, the default Category, the default Link Category, the default image sizes, and the optional Post via e-mail feature. Reading The settings in the Settings Reading SubPanel are few in number, but still important. You can decide if you want posts, or a "static" Page, displayed as your blog's front (main) page. You can also adjust how many posts are displayed on that main page. ! Like this

! Now your own choice what s a display your front page ! Your post ! Or your static page like Home or about us
PAGE 184 OF 185! !

PHP PROGRAMMING !

Discussion The Settings Discussion SubPanel allows you to control settings concerning incoming and outgoing comments, pingbacks and trackbacks. You can also control from this SubPanel the circumstances under which your blog sends you e-mail notifying you about the goings on at your site, and you can decide if your blog should show Avatars and their ratings. Media The Settings Media SubPanel allows you to determine where images, documents, and other media files will be linked to when inserted into the body of a post and to specify the maximum dimensions in pixels to use when inserting an image into the body of a post. Privacy The Settings Privacy SubPanel controls your blog visibility to search engines such as Google and Technorati. You can decide if you would like your blog to be visible to everyone, including search engines (like Google, Sphere, Technorati) and archivers. If you don't want your blog available to the search engines you can block search engines, but allow normal visitors to see your site. Permalinks For a nice introduction to Permalinks, check out the Pretty Permalinks section of Introduction to Blogging. But briefly, and to quote the Settings Permalinks SubPanel itself:

PAGE 185 OF 185!

NETMAX TECHNOLOGIES

You might also like