HTML

Document Sample
HTML Powered By Docstoc
					Learn HTML (Web Programming): Part-
Welcome to Sumon Seleem’s Web Programming Tutorial to help the newbies to learn about the
basics of Web Programming. So if you want to make your own website or want to become a
Web Programmer, this is right place that will guide you to start your journey.

Are you ready? If yes then let’s start…




       Introduction-to-HTML

We’ll start with HTML which stands for Hyper Text Markup Language and refers to a system
for communicating to a Web browser how the contents of a page will be displayed.

Introduction to HTML

HTML is not actually a programming language. It is a markup language which uses markup tags
to describe web pages.

A HTML document has a .html/.htm extension which tells the browser that it is a HTML
document.

Things We Need

First we need some instruments to make ourselves ready to start learning HTML.

Here are the tools I prefer:

      A Text-Editor (Notepad/Notepad++)
      Web Browser (Internet Explorer, Mozilla, Google Chrome, Opera)
I prefer to use Notepad++ for its user-friendly interface and it’ll help you to identify the tags
more easily as it has a beautiful syntax highlighting system. Download the latest version of
Notepad++ from here and install it to start. You can also use the default Windows Notepad to
start with.

HTML Tags and Elements

An element in HTML is a term that is used to describe individual parts of a website and HTML
tags are keywords surrounded by angle brackets like <html>.

HTML tags normally comes with a pair. The first one is the start tag which is also called the
opening tag and the last one is the end tag which is also known as the closing tag.

Here’s a simple example to describe the thing easily:

1 <html>

2 <body>

3

4 <h1>My First Heading</h1>

5 <p>My First Paragraph.</p>

6

7 </body>

8 </html>


Explanation
1 <html>

2 <body>

3

4 </body>

5 </html>



A HTML document starts with <html> tag and ends with </html> tag.

Then we need to define the HTML body element.
The body element has a start tag <body> and an end tag </body>. Everything between these two
tags will be the main part of a HTML document.

1 <h1>My First Heading</h1>

2 <p>My First Paragraph.</p>



HTML headings are defined with the <h1> to <h6> tags.

Here we have defined a HTML heading which starts with <h1> start tag and ends with </h1>
end tag.

The second line is a paragraph element which is defined by <p> tags. A paragraph element has a
<p> start tag and a </p> end tag.

Practice

In this tutorial we have learned:

         What is HTML?
         HTML Basics
         HTML Elements
         HTML Tags

Now you should try yourself to understand this codes and practice it .

Start Notepad/Notepad++ on your PC and paste the above code in it.

Then save the file as index.html and open the page/document on your browser.

If you have any questions regarding this tutorial feel free to ask me on the comment area.

In our next tutorial we will learn about more HTML elements and tags.

Image Credit: Charltonkings




PHP: Function to Check If Email Address is Valid
Function to Check If Email Address is Valid
Here is a PHP function to check if an email address is valid. First we perform the basic syntax-check and then we check if the host
assigned to the email address has a valid MX or A record.
Note that, the function will always return false in local environment or in offline servers because of the use of checkdnsrr() function which
tries to get the MX and A records of a domain.


1 <?php
2
3 function isValidEmail($email)
4{
5 //Perform a basic syntax-Check
6 //If this check fails, there's no need to continue
7 if(!filter_var($email, FILTER_VALIDATE_EMAIL))
8 {
9  return false;
10 }
11
12 //extract host
13 list($user, $host) = explode("@", $email);
14 //check, if host is accessible
15 if (!checkdnsrr($host, "MX") && !checkdnsrr($host, "A"))
16 {
17 return false;
18 }
19
20 return true;
21 }
22
23 ?>


If you find this PHP function useful or have something to share, comment section is always open for you




PHP: Function to Get Zodiac/Starsign From Day and
Month
Here is a small PHP Snippet to get Zodiac Sign from the day of a month. Just put the day and a month value in numeric and the function will
return you the zodiac sign.


1 <?php
2
3 $d = date('j');
4
5 $m = date('n');
6
7 function starsign($d,$m)
8{
9 if(($m==3)&&($d>20))
10 {
11 return "Aries";
12 }
13 elseif(($m==4)&&($d<21))
14 {
15 return "Aries";
16 }
17 elseif(($m==4)&&($d>20))
18 {
19 return "Taurus";
20 }
21 elseif(($m==5)&&($d<22))
22 {
23 return "Taurus";
24 }
25 elseif(($m==5)&&($d>21))
26 {
27 return "Gemini";
28 }
29 elseif(($m==6)&&($d<22))
30 {
31 return "Gemini";
32 }
33 elseif(($m==6)&&($d>21))
34 {
35 return "Cancer";
36 }
37 elseif(($m==7)&&($d<23))
38 {
39 return "Cancer";
40 }
41 elseif(($m==7)&&($d>22))
42 {
43 return "Leo";
44 }
45 elseif(($m==8)&&($d<24))
46 {
47 return "Leo";
48 }
49 elseif(($m==8)&&($d>23))
50 {
51 return "Virgo";
52 }
53 elseif(($m==9)&&($d<23))
54 {
55 return "Virgo";
56 }
57 elseif(($m==9)&&($d>22))
58 {
59 return "Libra";
60 }
61 elseif(($m==10)&&($d<24))
62 {
63 return "Libra";
64 }
65 elseif(($m==10)&&($d>23))
66 {
67 return "Scorpio";
68 }
69 elseif(($m==11)&&($d<23))
70 {
71 return "Scorpio";
72 }
73 elseif(($m==11)&&($d>22))
74 {
75 return "Sagittarius";
76 }
77 elseif(($m==12)&&($d<24))
78 {
79 return "Sagittarius";
80 }
81 elseif(($m==12)&&($d>23))
82 {
83 return "Capricorn";
84 }
85 elseif(($m==1)&&($d<21))
86 {
87 return "Capricorn";
88 }
89 elseif(($m==1)&&($d>20))
90 {
91 return "Aquarius";
92 }
93 elseif(($m==2)&&($d<19))
94 {
95 return "Aquarius";
96 }
97 elseif(($m==2)&&($d>18))
98 {
99  return "Pisces";
100 }
101 elseif(($m==3)&&($d<21))
102 {
103 return "Pisces";
104 }
105 }
106 ?>


If you have anything to share or need any help regarding the post, feel free to comment in the comment section.


A Simple Function in PHP to detect or trace the IP Address and User Agent (Browser) of an user or visitor.


PHP – Function to detect IP Address:
1 <?php

2 /**

3 * Detect IP Address

4*

5 */

6


7 function ip() {

8 if (isset($_SERVER)) {
9 if(isset($_SERVER['HTTP_CLIENT_IP'])){

10 $ip = $_SERVER['HTTP_CLIENT_IP'];

11 }

12 elseif(isset($_SERVER['HTTP_FORWARDED_FOR'])){

13 $ip = $_SERVER['HTTP_FORWARDED_FOR'];

14 }

15 elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR'])){

16 $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];

17 }

18 else{

19 $ip = $_SERVER['REMOTE_ADDR'];

20 }

21 }

22 else

23 {

24 if (getenv( 'HTTP_CLIENT_IP')) {


25 $ip = getenv( 'HTTP_CLIENT_IP' );

26 }

27 elseif (getenv('HTTP_FORWARDED_FOR')) {

28 $ip = getenv('HTTP_FORWARDED_FOR');

29 }

30 elseif (getenv('HTTP_X_FORWARDED_FOR')) {


31 $ip = getenv('HTTP_X_FORWARDED_FOR');
32 }

33 else {

34 $ip = getenv('REMOTE_ADDR');

35 }

36 }

37 return $ip;

38 }

39

40 ?>


PHP – Function to detect User Agent or Browser:
1 <?php

2 /**

3 * Detect Browser/User Agent

4*

5 */

6

7 function ua()

8{

9 if(stristr($_SERVER['HTTP_USER_AGENT'],'Opera Mini'))

10 {

11 if(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']))

12 {

13 $browser = addslashes(strip_tags($_SERVER['HTTP_X_OPERAMINI_PHONE_UA']));
14 }

15 else

16 {

17 $browser = addslashes(strip_tags($_SERVER['HTTP_USER_AGENT']));

18 }

19 }

20 else

21 {

22 $browser = addslashes(strip_tags($_SERVER['HTTP_USER_AGENT']));

23 }

24 return $browser;

25 }

26

27 ?>


Usage:
1 <?php

2 $ip = ip();


3 $browser = ua();

4


5 echo "Your IP Address: ".$ip;

6 echo "Your Browser: ".$browser;

7 ?>


Image Credit:

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:58
posted:6/24/2011
language:English
pages:10