Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Monday, September 23, 2013

PHP-3 : Addition of 2 numbers

Refer this introduction , before doing any PHP program.
PHP Introduction - And some useful points in Programming
  • Open Dreamweaver to write php code , with in the body tag .That is , 
<body>
.......................} php code 
</body> .
and save it (as .php) under the www directory of wamp server.
  • Then click wamp-->localhost to view it in the browser.
=================================================================
<!DOCTYPE html>
<html>
<body>

<?php
$x=5;
$y=6;
$z=$x+$y;
echo $z;
?>

</body>
</html>

Output :
11
========================================================
If we want to display 5, and 6 along with 11, do the program like this:

<!DOCTYPE html>
<html>
<body>

<?php
$x=5;
$y=6;
echo $x ;
echo " +" ;
echo "<br>";
echo $y;
echo "<br>";
echo "..........";
$z=$x+$y;
echo "<br>";
echo $z;
?>

</body>
</html>

Output :
5 +
6
-------
11

Note : 
In PHP these letters (x,y,z etc) are called variables.Variables are "containers" for storing information:
Rules for PHP variables:
  • A variable starts with the $ sign, followed by the name of the variable
  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case sensitive ($y and $Y are two different variables)

Back to HOME & PHP 

PHP-2 : Using color ($)

Refer this introduction , before doing any PHP program.
PHP Introduction - And some useful points in Programming
  • Open Dreamweaver to write php code , with in the body tag .That is , 
<body>
.......................} php code 
</body> .
and save it (as .php) under the www directory of wamp server.
  • Then click wamp-->localhost to view it in the browser.
=================================================================

<!DOCTYPE html>
<html>
<body>

<?php
$color="red";
echo "My car is " . $color . "<br>";
?>  

</body>
</html>

Output :

My car is red

Note :
In PHP , all variables are case-sensitive.
$color="red"...is correct ($COLOR, and $coLOR are wrong.)

Back to HOME & PHP 

PHP-1 : My first PHP

Refer this introduction , before doing any PHP program.
PHP Introduction - And some useful points in Programming
  • Open Dreamweaver to write php code , with in the body tag .That is , 
<body>
.......................} php code 
</body> .
and save it (as .php) under the www directory of wamp server.
  • Then click wamp-->localhost to view it in the browser.
=================================================================

<!DOCTYPE html>
<html>
<body>

<h1>My First PHP Page</h1>

<?php
echo "Hello PHP!";
?>

</body>
</html>

Output : 



Note :

  • "echo" is used to output the text "Hello World!" on a web page (echo is not case-sensitive, that is ,we can write ECHO,EcHo , echo...etc)In PHP there is two basic ways to get output: , ECHO and PRINT . echo can output one or more strings , and can be used with or without parantheses: echo or echo() and print can only output one string, and returns always 1 , also can be used with or without parantheses: print or print() .
  • Always add the <!DOCTYPE> declaration to your HTML documents, so that the browser knows what type of document to expect.That is , when you use a DOCTYPE declarations in your web pages (and many HTML editors likeDreamweaver add them in automatically), you are telling the web browser what version of (X)HTML your web page should be displayed in.
  • A string is a sequence of characters, like "Hello World !".
    A string can be any text inside quotes. You can use single or double quotes:
    That is , we can write "Hello World !" & 'Hello World !'
    ==================================================
Back to HOME & PHP 

PHP Introduction - And some useful points in Programming

Refer WAMP Server & PHP-DATABASE Connection also..
===============================================

How and where to save php files ? To know , click here.

(1) : What is PHP ?
  • PHP files can contain text, HTML, CSS, JavaScript, and PHP code
  • PHP ( Hypertext Preprocessor) is a server scripting language, and is a powerful tool for making dynamic and interactive Web pages quickly.
  • PHP code are executed on the server, and the result is returned to the browser as plain HTML
  • It is a file with the extension .php (dot php) .
Click here to know about HTML Tags .


(2) : Where to type PHP ?
  • Try writing PHP code with this online editor.
  • You can use WAMP server (to view files in localhst)  , and  Dreamweaver. (Click WAMP to install). To know more about WAMP Server, click HERE.
  • There is another and useful IDE called "NetBeans" . You can use this editor for other programming also. Download NetBeans from here for free. (You need JDK or Java Development Kit for installing NetBeans . If you have no Java platform on your system , download from here (which contains JDK+NetBeans ) .

(3) : Set Up PHP on Your Own PC

 if your server does not support PHP, you must:
  • install a web server
  • install PHP
  • install a database, such as MySQL
The official PHP website (PHP.net) has installation instructions for PHP:   Click the official link 
Installation and Configuration


How to check if a PHP function is available on the server?
Write any php code and then you should open the file in a browser and see the result :)

(4) : Basic structure of PHP

A PHP script starts with <?php and ends with ?>:

<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>


<?php
// This is a simple PHP program
echo "Hello World!";
?>

</body>
</html>


Note :

A comment in PHP code is a line that is not read/executed as part of the program. Its only purpose is to be read by someone who is editing the code!

3 types of commands are there in PHP.
  • #
  • //
  • /*  ....... */

(5) : What PHP contains ??

  • PHP files can contain text, HTML, CSS, JavaScript, and PHP code.
Study HTML to know the basic ..

Before proceeding, we should have a little knowledge about CSS and Java Script also. 
These will come in detail on later sessions. 
But , keep this simple points in mind :

(a) : What is JavaScript ?

JavaScript is programming code that can be inserted into HTML pages.
JavaScript is the scripting language of the Web.
All modern HTML pages are using JavaScript to add functionality, validate input, communicate with web servers, and much more.


To insert a JavaScript into an HTML page, use the <script> tag.
The <script> and </script> tells where the JavaScript starts and ends.
The lines between the <script> and </script> contain the JavaScript:

Example : 

<html>

......

        <script>

       alert("My First JavaScript");

        </script>

......

</html> 



(b) : What is CSS (Cascading Style Sheets) ?

An HTML document can be displayed with different styles.
Styles define how to display HTML elements.
In the case of large sites, if we add styles and color in each page , it became large.
That is , Development of large web sites, where fonts and color information were added to every single page, became a long and expensive process. 
To solve this problem , all formatting could be removed from the HTML document, and stored in a separate CSS file. 
CSS defines HOW HTML elements are to be displayed.

Thus, save a lot of work with CSS..Just like JavaScript, CSS also using along with HTML.

A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets:

Example : 


<html>

.........

        p {color:red;text-align:center;}

..........

</html>


(6) : What is SERVER side scripting & CLIENT side scripting??

?? In the context of web programming, what are the differences between Server-side programming and Client-side programming? Which languages belong to which, and when do you use each of them?

== 3 points you have to note;
  • The Server - This party is responsible for serving pages. 
  • The Client - This party requests pages from the Server, and displays them to the user. On most cases, the client is a web browser. 
  • The User - The user uses the Client in order to surf the web, fill in forms, watch videos online, etc.
(a) Server-side programming :
Server-side programming is writing code that runs on the server, using languages supported by the server (such as Java, ASP,PHP, C#; it is possible to write code that executes on the server-side in JavaScript).
Uses 
  • Process user input. 
  • Display pages. 
  • Structure web applications. 
  • Interact with permanent storage (SQL, files).
(b) Client-side programming

Client-side programming is writing code that will run on the client, and is done in languages that can be executed by the browser, such as JavaScrip,HTML,CSS...etc.
Uses
  • Make interactive webpages. 
  • Make stuff happen dynamically on the web page. 
  • Interact with temporary storage, and local storage (Cookies, localStorage). 
  • Send requests to the server, and retrieve data from it. 
  • Provide a remote service for client-side applications, such as software registration, content delivery, or remote multi-player gaming.
(c) Basic Example
  • The User opens his web browser (the Client). 
  • The User browses to http://google.com. 
  • The Client (on the behalf of the User), sends a request to http://google.com (the Server), for their home page. 
  • The Server then acknowledges the request, and replies the client with some meta-data (calledheaders), followed by the page's source. 
  • The Client then receives the page's source, and renders it into a human viewable website. 
  • The User types http://programming-bca-mca.blogspot.com/ into the search bar, and presses Enter
  • The Client submits that data to the Server. 
  • The Server processes that data, and replies with a page matching the search results. 
  • The Client, once again, renders that page for the User to view.
(7) : What is ASP and PHP difference ??

Both are server side programming . When building web sites, ASP & PHP can interact with Databases and exchange information.
  • ASP (Active Server Pages),is from Microsoft and is used with IIS (Internet Information Server) that runs on Microsoft Servers.It uses MS-SQL. 
  • And PHP ( Hypertext Preprocessor) , runs on various platforms like Linux, Unix, Windows and Solaris servers and it also has an NT server version.It uses MySQL. 
  • ASP is closed source (Closed Source means that the source-code is not available to the public. With Closed Source products you are not allowed to modify, edit, reverse-compile, or otherwise view or change the inner-workings of the product. ) 
  • But PHP is open source (Open Source means that the source-code (the stuff the program/website/driver/etc is made from) is available for anyone to look at and modify for their own purposes). 
  • ASP is a (language-independent) framework, PHP is a language.

(8) : Other doubt you may have...

1 : Difference between Scripting Language & Programming Language.

Usually ,scripting languages are a sub-sets of programming languages.

Scripting Language are languages that allow you to send commands directly to a system that executes these commands. These commands are read line by line and executed. An error is issued when a line cannot be executed for any reasn (wrong syntaxor illegal operation,...). e.g. Python, shell-script, Matlab.

Programming Language are languages that allow you to create a program by writing structured code that is read all at once by the system, checked for errors, and translated into an unreadable format that the machine can then execute. e.g. Java, C/C++, Visual Basic...


(Post if you have any other...)

================================================
===========================================


Back to PHP & WAMP SERVER
Back to HOME

Sunday, September 15, 2013

H8 - Formatting Options in HTML

Open note pad (wordpad or MS word) , then type the commands as given below : 
Save the file as . htm (dot htm) or   . html (dot html) .
Open any web page , and browse the created page  to view the  web page .
Refer HTML - An Introduction before creating any web page.
===============================================
<html>
<head>
<Title>Formatting Tags</title>
</head>
<body>
    <br><b>Bold</b>
    <br><i>Italilcs</i>
    <br><u>Underline</i>
    <br><b><i><u>Bold-Italilcs-Underline</b></i></u>
    <br>Look at this<sup>Superscript</sup>
    <br>Look at this<sub>Subscript</sub>
    <br>Look at this<strong>Strong Text</strong>
    <br>Look at this<em>Emphasized Text</em>
    <br>Look at this<strike>Striked Out Text</strike>
    <br>Look at this<big>Big Text</big>
    <br>Look at this<small>Small Text</small>
            <br>Look at this<center>Text in Centre</centre>
    <br><font face="Arial">This is Arial Font></font>
    <br><font face="Courier"size="5">This is Courier Font with size 5></font>
    <br><font face="Times New Roman"size="10"color="red">Times New Roman Font with size 10 & Red color ></font>
    <br><font size="1">Font Size=1></font>
    <br><font size="2">Font Size=2></font>
    <br><font size="5">Font Size=5></font>
    <br><font color="blue">Blue Color></font>
    <br><font color="green">Green Color></font>

</body>
</html>

OUTPUT : 


Note : Formatting Options in HTML are ; 

1  : <br> = BOLD
2  : <i>  = ITALICS
3  : <u>  = UNDERLINE
4  : <sup>      = SUPERSCRIPT
5  : <sub>      = SUBSCRIPT
6  : <strong>   = BOLD FACE
7  : <em>       = EMPHASIZED TEXT
8  : <strike>   = STRIKEOUT EFFECT
9  : <big>      = BIGGER THAN NORMAL TEXT
10 : <small>    = SMALLER THAN NORMAL TEXT
11 : <centre>   = ALIGN TEXT & IMAGES AT CENTRE
12 : <font>     = TO CHANGE FONT ; 
Font has 3 attributes namely FACE,SIZE,COLOR : Color attributes values ranges from 000000 to FFFFFF.

13 : <bgcolor>  = TO SET BACKGROUND COLOR
14 : <basefont> = SETS OR CHANGE THE ENTIRE TEXT IN THE PAGE
(13 & 14 are given in the coming 2 programs)

Back to HTML  

PREVIOUS CHAPTER                 NEXT CHAPTER

H7 - Types of Heading in HTML

Open note pad (wordpad or MS word) , then type the commands as given below : 
Save the file as . htm (dot htm) or   . html (dot html) .
Open any web page , and browse the created page  to view the  web page .
Refer HTML - An Introduction before creating any web page.
===============================================
<html>
<head>
<Title>Heading</title>
</head>
<body>
    <h1>Priyada Mohanan</h1>
    <h2>Priyada Mohanan</h2>
    <h3>Priyada Mohanan</h3>
    <h4>Priyada Mohanan</h4>
    <h5>Priyada Mohanan</h5>
    <h6>Priyada Mohanan</h6>
        <h1 align="right">Priyada Mohanan</h3>
<h2 align="center">Priyada Mohanan</h1>
<h3 align="left">Priyada Mohanan</h2>
     
</body>
</html>

OUTPUT : 



Note : 
<h1> to <h6> is used to give heading.
<h1> is the biggest heading , and <h6> is the smallest one.
Note that , We can use alignment option (left,right,centre etc) with the heading tags.

Back to HTML  

PREVIOUS CHAPTER                 NEXT CHAPTER

Monday, September 9, 2013

H6 - To draw horizontal lines in a web page

Open note pad (wordpad or MS word) , then type the commands as given below : 
Save the file as . htm (dot htm) or   . html (dot html) .
Open any web page , and browse the created page  to view the  web page .
Refer HTML - An Introduction before creating any web page.
===============================================
<html>
<head>
<Title>Drawing lines</title>
</head>
<body>
    Hello world
        <hr noshade size="5" align="centre" width="50%">
    Welcome to HTML
        <hr size="15" align="left" width="75%">
    Learn how to draw horizontal lines
        <hr size="20" align="right" width="75%">
</body>
</html>

OUTPUT : 



Note : 
<hr> is used to draw horizontal lines.
It has 4 attributes (Check what is an attributes, from Introduction)
1 : Align (left,right,centre)
2 : Width (length in pixels)
3 : Size (Thickness in pixels)
4 : Noshade (To draw in single color)
Note that , We are giving all these attributes with in the tags.


Back to HTML  

PREVIOUS CHAPTER                 NEXT CHAPTER

H5 - SPACE between text

Open note pad (wordpad or MS word) , then type the commands as given below : 
Save the file as . htm (dot htm) or   . html (dot html) .
Open any web page , and browse the created page  to view the  web page .
Refer HTML - An Introduction before creating any web page.
===============================================
<html>
<head>
<Title>My web page</title>
</head>
<body>
   <pre>
      Priyada Mohanan
      Ernakulam,Cochin
      Kerala
      India
   </pre>
</body>
</html>

OUTPUT : 



Note : 
<br> is used to start a new line.
Here instead of <br> , we add <pre>.
While using <pre> , no need to use <br> in each line.(Check previous example also.)

Back to HTML  


H4 - Address in a web page

Open note pad (wordpad or MS word) , then type the commands as given below : 
Save the file as . htm (dot htm) or   . html (dot html) .
Open any web page , and browse the created page  to view the  web page .
Refer HTML - An Introduction before creating any web page.
===============================================
<html>
<head>
<Title>My web page</title>
</head>
<body>
<br>Priyada Mohanan</br>
<br>Ernakulam,Cochin</br>
<br>Kerala</br>
<br>India</br>
</body>
</html>

OUTPUT : 


Note : <br> is used to start a new line.It is an EMPTY(STAND ALONE) tag.
That is <br> has no closing tag(check introduction)
Check the difference in output, of this and next example.

Back to HTML