Information Technology
Information Technology
Information Technology
Ans :- 1. Internet :
The network formed by the co-operative interconnection of millions of
computers, linked together is called Internet. Internet comprises of :
People : People use and develop the network.
Resources : A collection of resources that can be reached from those
networks.
A setup for collaboration : It includes the member of the research and
educational committees worldwide.
2. Intranet :
It is an internal private network built within an organization using Internet and
World Wide Web standards and products that allows employees of an
organization to gain access to corporate information.
3. Extranet :
It is the type of network that allows users from outside to access the Intranet
of an organization.
Difference between Internet, Intranet and Extranet :
Point of
difference Internet Intranet Extranet
Accessibility
Public Private Private
of network
To share information
Specific to an with suppliers and
Availability Global system.
organization. vendors it makes the
use of public network.
It is largest in
No. of The minimal number The connected devices
number of
computers of devices are are more comparable
connected
connected connected. with Intranet.
devices.
Single/ Multiple
Owner No one. Single organization.
organization.
It’s purpose is to
It’s purpose is to It’s purpose is to share
share
Purpose of the share information information between
information
network throughout the members and external,
throughout the
organization. members.
world.
It is dependent
It is enforced via
on the user of the It is enforced via
Security firewall that separates
device connected firewall.
internet and extranet.
to network.
Employees of the
Employees of the
Users General public. organization which are
organization.
connected.
It is maintained by It is maintained by
CIO. HR or CIO. HR or
It is maintained
Maintenance communication communication
by ISP.
department of an department of an
organization. organization.
Point of
difference Internet Intranet Extranet
It is more
It is also less
Economical economical to It is less economical.
economical.
use.
But it is difficult for humans to remember this IP address. Thus to find the
location on the Internet easily, DNS was invented. DNS stands for Domain
Name Server. It implements a distributed database which translates IP
address into a unique alphanumeric address which is referred to as Domain
Names. Basically, a domain name is the sequence of letters and or numbers
separated by one or more period (“.”). It is just like a pointer to a unique IP
address on the computer network. As an analogy one can consider Domain
name as address and DNS as address book of the Internet.
Example-1:
Lets us consider an example for domain name;
www.google.com, www.yahoo.com
In this “yahoo.com” is called domain name.
“www.” tells the browser to look for World Wide Web Interface for that
domain.
As from the above example, it is clear that domain names are easy to
remember than an IP address.
Example-2:
Assume that the IP address of www.yahoo.com is 69.147.76.15. It is easy to
remember www.yahoo.com as compared to IP address 69.147.76.15.
Thus, we can say like these; domain name refers to the string of letters
associated with an IP address and DNS is a mechanism used to convert an
IP address to the domain name.
DNS is a TCP/IP protocol used on different platforms. The domain name space is
divided into three different sections: generic domains, country domains, and inverse
domain.
Generic Domains
o It defines the registered hosts according to their generic behavior.
o Each node in a tree defines the domain name, which is an index to the DNS
database.
o It uses three-character labels, and these labels describe the organization type.
o (diagrm –nxt pge)
o Country Domain
o The format of country domain is same as a generic domain, but it uses two-
character country abbreviations (e.g., us for the United States) in place of
three character organizational abbreviations.
o Inverse Domain
o The inverse domain is used for mapping an address to a name. When the
server has received a request from the client, and the server contains the files
of only authorized clients. To determine whether the client is on the
authorized list or not, it sends a query to the DNS server and ask for mapping
an address to the name.
o
Here, the server is the server and client is the receiver. The above diagram shows 3
steps for successful connection. A 3-way handshake is commonly known as SYN-
SYN-ACK and requires both the client and server response to exchange the data. SYN
means synchronize Sequence Number and ACK means acknowledgment. Each
step is a type of handshake between the sender and the receiver.
The diagram of a successful TCP connection showing the three handshakes is shown
below:
Step 1: SYN
SYN is a segment sent by the client to the server. It acts as a connection
request between the client and server. It informs the server that the client wants to
establish a connection. Synchronizing sequence numbers also helps synchronize
sequence numbers sent between any two devices, where the same SYN segment asks
for the sequence number with the connection request.
Step 2: SYN-ACK
It is an SYN-ACK segment or an SYN + ACK segment sent by the server. The ACK
segment informs the client that the server has received the connection request and it
is ready to build the connection. The SYN segment informs the sequence number
with which the server is ready to start with the segments.
Step 3: ACK
ACK (Acknowledgment) is the last step before establishing a successful TCP
connection between the client and server. The ACK segment is sent by the client as
the response of the received ACK and SN from the server. It results in the
establishment of a reliable data connection.
After these three steps, the client and server are ready for the data communication
process. TCP connection and termination are full-duplex, which means that the data
can travel in both the directions simultaneously.
The client is the data transmitter and the server is a receiver in a data transmission
process between the sender and receiver. Consider the below TCP termination
diagram that shows the exchange of segments between the client and server.
The diagram of a successful TCP termination showing the four handshakes is shown
below:
Let's discuss the TCP termination process with the help of six steps that includes the
sent requests and the waiting states. The steps are as follows:
Step 1: FIN
FIN refers to the termination request sent by the client to the server. The first FIN
termination request is sent by the client to the server. It depicts the start of the
termination process between the client and server.
Step 2: FIN_ACK_WAIT
The client waits for the ACK of the FIN termination request from the server. It is
a waiting state for the client.
Step 3: ACK
The server sends the ACK (Acknowledgement) segment when it receives the FIN
termination request. It depicts that the server is ready to close and terminate the
connection.
Step 5: FIN
The FIN segment is now sent by the server to the client. It is a confirmation signal
that the server sends to the client. It depicts the successful approval for the
termination.
Step 6: ACK
The client now sends the ACK (Acknowledgement) segment to the server that it has
received the FIN signal, which is a signal from the server to terminate the connection.
As soon as the server receives the ACK segment, it terminates the connection.
Q5) TELNET –
It provides bi-directional text-oriented services for remote login to the hosts over the
network. TELNET (Terminal Network):
• TELNET is client-server application that allows a user to log onto remote machine and lets
the user to access any application program on a remote computer.
• TELNET uses the NVT (Network Virtual Terminal) system to encode characters on the
local system.
• On the server (remote) machine, NVT decodes the characters to a form acceptable to the
remote machine.
File Transfer Protocol, FTP − It is a client-server based protocol for transfer of files between
client and server over the network.
• File Transfer Protocol (FTP) is the standard mechanism provided by TCP/IP for copying a
file from one host to another.
• FTP establishes two connections between the hosts
• One connection is used for data transfer, the other for control information (commands and
responses)
• Separation of commands and data transfer makes FTP more efficient
• FTP uses two well-known TCP ports: Port 21 is used for the control connection, and port 20
is used for the data connection.
HTTP
o Hyper Text Transfer Protocol, HTTP − It is the underlying protocol for world
wide web. It defines how hypermedia messages are formatted and
transmitted.
o It is a protocol used to access the data on the World Wide Web (www).
o The HTTP protocol can be used to transfer the data in the form of plain text,
hypertext, audio, video, and so on.
o This protocol is known as HyperText Transfer Protocol because of its efficiency
that allows us to use in a hypertext environment where there are rapid jumps
from one document to another document.
o HTTP is similar to the FTP as it also transfers the files from one host to another
host. But, HTTP is simpler than FTP as HTTP uses only one connection, i.e., no
control connection to transfer the files.
o HTTP uses the services of TCP on well-known port 80.
o Accessing of web page is based on URL
o HTTP is similar to SMTP as the data is transferred between client and server.
The HTTP differs from the SMTP in the way the messages are sent from the
client to the server and from server to the client. SMTP messages are stored
and forwarded while HTTP messages are delivered immediately.
Q6)
Ans:- Routing is the process of selecting a path for traffic in a network or between or
across multiple networks. Broadly, routing is performed in many types of networks,
including circuit-switched networks, such as the public switched telephone network,
and computer networks, such as the Internet.
Interdomain Routing
Interdomain Routing is the protocol in which the routing algorithm works both within and
between domains. Domains must be connected in some way, for hosts inside one domain to
exchange data with hosts in other domains. This connection within domains is governed by
the interdomain routing protocols. This is often done using the Border Gateway Protocol
(BGP). It is used in Path Vector Routing using which interdomain routing is performed.
In path vector routing, the routing depends on the analysis of the path from the nodes in the
current domain to the node in the other domain, and not on the distance between nodes.
Intradomain Routing
Intradomain Routing is the routing protocol that operates only within a domain. In other
words, intradomain routing protocols are used to route packets within a specific domain, such
as within an institutional network for e-mail or web browsing. Unlike interdomain routing
protocols, it doesn't communicate with other domains. There are two types of protocols used
for intradomain routing:
2. Link State Routing (uses Open Shortest Path First or OSPF) In link state routing,
each node in a domain stores information about all the other nodes in the domain, in
other words, the routing table of each node stores information about the entire
topology of the domain. Since each node has all the information about the domain at
its disposal, Dijkstra's algorithm is used to calculate the best routing path. This is
possible due to OSPF, and this is also its advantage.
Unicast:
When the hosts are responsible for parsing data from broadcast packets.
When all the hosts require the same data.
It has one sender and one It has one or more senders and
1. receiver. multiple receivers.
It sends data from one device to It sends data from one device to
2. single device. multiple devices.
It has one sender and one It has one or more senders and
1. receiver. multiple receivers.
It sends data from one device to It sends data from one device to
2. single device. multiple devices.
It does not scale well for It does not scale well across large
4. streaming media. networks.
• Electronic mail, or more commonly email, used to communicate with different users in
internet
• Email uses following protocols for storing & delivering messages, They are :
1. SMTP (Simple Mail Transfer Protocol)
2. POP (Post Office Protocol)
3. IMAP (Internet Message Access Protocol)
What is IPv6?
IPv6 is the most recent version of the Internet Protocol. This new IP
address version is being deployed to fulfill the need for more
Internet addresses. It was aimed to resolve issues that are
associated with IPv4. With 128-bit address space, it allows 340
undecillion unique address space. IPv6 is also called IPng (Internet
Protocol next generation).
Internet Engineer Taskforce initiated it in early 1994. The design
and development of that suite are now called IPv6.
IPv4 ADDRESSING SCHEME
IP addresses falls into two types:
• Classful IP addressing is a legacy scheme which divides the whole IP address pools
into 5 distinct
classes—A, B, C, D and E.
Classful Addressing :
Class A
The first octet denotes the network address, and the last three octets are the host
portion. Any IP address whose first octet is between 1 and 126 is a Class A address.
Note that 0 is reserved as a part of the default address and 127 is reserved for internal
loopback testing.
Format: network.host.host.host
Default subnet mask = 255.0.0.0 or (slash notation) /8
Class B
The first two octets denote the network address, and the last two octets are the host
portion. Any address whose first octet is in the range 128 to 191 is a Class B address.
Format: network.network.host.host
Default subnet mask =255.255.0.0 or /16
Class C
The first three octets denote the network address, and the last octet is the host portion.
The first octet range of 192 to 223 is a Class C address.
Format: network.network.network.host
Default subnet mask = 255.255.255.0 or /24
Class D
Used for multicast. Multicast IP addresses have their first octets in the range 224 to 239.
Class E
Reserved for future use or research purpose and includes the range of addresses with a
first octet from
240 to 255.
Encryption and authentication is not provided in IPv4 Encryption and authentication is provided in
(Internet Protocol Version 4). IPv6 (Internet Protocol Version 6)
IPv4 addresses are usually represented in dot-decimal An IPv6 address is represented as eight
notation, consisting of four decimal numbers, each groups of four hexadecimal digits, each
ranging from 0 to 255, separated by dots. group representing 16 bits.
Sender and forwarding routers performs fragmentation in Fragmentation is performed only by the
IPv4 sender in IPv6.
In IPv4, security features relies on application In IPv6, there is an inbuilt security feature
named IPSEC.
End to end connection integrity cannot be achieved in End to end connection integrity can be done
IPv4. in IPv6.
IPv4 supports DHCP and Manual address configuration IPv6 supports renumbering and auto
address configuration.
IPv4 addresses are 32-bit long IPv6 addresses are 128 bits long.
The address space in IPv4 is 4.29 ×109 The address space in IPv6 is 3.4 ×1038
IPv4 has a broadcast message transmission scheme. Multicast and Anycast message transmission
scheme is available in IPv6.
What is congestion?
A state occurring in network layer when the message traffic is so heavy that it slows
down network response time.
Effects of Congestion
As delay increases, performance decreases.
If delay increases, retransmission occurs, making situation worse.
Imagine a bucket with a small hole in the bottom.No matter at what rate water enters
the bucket, the outflow is at constant rate.When the bucket is full with water
additional water entering spills over the sides and is lost.
Similarly, each network interface contains a leaky bucket and the following steps are
involved in leaky bucket algorithm:
1. When host wants to send packet, packet is thrown into the bucket.
2. The bucket leaks at a constant rate, meaning the network interface transmits
packets at a constant rate.
3. Bursty traffic is converted to a uniform traffic by the leaky bucket.
4. In practice the bucket is a finite queue that outputs at a finite rate.
The leaky bucket algorithm enforces output pattern at the average rate, no matter how
bursty the traffic is. So in order to deal with the bursty traffic we need a flexible
algorithm so that the data is not lost. One such algorithm is token bucket algorithm.
Ways in which token bucket is superior to leaky bucket: The leaky bucket
algorithm controls the rate at which the packets are introduced in the network, but it is
very conservative in nature. Some flexibility is introduced in the token bucket
algorithm. In the token bucket, algorithm tokens are generated at each tick (up to a
certain limit). For an incoming packet to be transmitted, it must capture a token and
the transmission takes place at the same rate. Hence some of the busty packets are
transmitted at the same rate if tokens are available and thus introduces some amount
of flexibility in the system.
• If bucket is full in token Bucket , tokens are discard not packets. While in leaky bucket,
packets are
discarded.
• Token Bucket can send Large bursts at a faster rate while leaky bucket always sends
packets at constant rate.
Security Issues
Network security is now of the utmost importance in today's environment, when
practically everything is connected via networks. Cyberattacks are a persistent threat
to networks, and the results can be disastrous. Network breaches can seriously harm
both people and organizations through identity theft and financial losses. To ensure
network security, there are a number of protective techniques that can be applied.
1. Firewalls: The first line of protection against network threats is the firewall. A
firewall is a network security device that monitors and restricts network traffic
based on predefined security rules. Firewalls, which may be deployed as
hardware or software, can prevent illegal network access.
2. Virtual Private Networks (VPNs): VPNs enable secure network access
through the internet. VPNs utilize encryption to safeguard data sent over the
network, making it more difficult for attackers to intercept and steal data.
VPNs are especially beneficial for distant workers who need to access the
network from locations other than the office.
3. Intrusion Detection and Prevention Systems (IDPS): IDPSs are intended to
identify and prevent network assaults. To identify and prevent suspect
network traffic, they employ a variety of approaches such as signature-based
detection, anomaly detection, and heuristic analysis. IDPSs can also be
programmed to respond to assaults automatically by restricting traffic or
shutting down vulnerable services.
4. Antivirus and Anti-Malware Software: Antivirus and anti-malware software
are critical for keeping viruses and other harmful software out of the network.
These applications monitor incoming and outgoing data for known risks and
prevent them from causing harm. Antivirus software should be updated on a
regular basis to guarantee that it can detect the most recent threats.
5. Patch Management: Keeping all software up to date is critical for network
security. Many software updates include security patches that fix
vulnerabilities that can be exploited by attackers. Regularly applying these
patches can prevent attackers from exploiting known vulnerabilities.
6. Access Controls: Access restrictions are used to limit network access to only
authorized users. Passwords, biometric authentication, and other
authentication techniques can be used to accomplish this. Access restrictions
should be evaluated and modified on a regular basis to ensure that only
authorized users have access to the network.
7. Employee Education and Training: Staff education and training are critical to
network security. Workers should be educated on the necessity of network
security and the dangers of network breaches. They should also be taught
how to detect and respond to questionable network behavior.
Finally, both people and companies must defend their networks against cyberattacks.
Applying the aforementioned security measures can assist to guarantee network
security. It's vital to remember that network security is a never-ending process that
requires ongoing monitoring and tweaking to stay up with new threats.
1.Password Complexity:
- Encourage users to create strong passwords that include a mix of
uppercase and lowercase letters, numbers, and special characters.
- Avoid easily guessable information such as birthdays, names, or
common words.
2. Password Length:
- Longer passwords are generally more secure. Encourage the use of
passphrases that are both easy to remember and difficult to crack.
3. Password Rotation:
- Regularly prompt users to change their passwords, especially for
critical systems and sensitive accounts. However, avoid overly
frequent changes, as this can lead to weaker passwords.
6. Password Storage:
- Store passwords securely using strong encryption methods. Avoid
storing plaintext passwords, and consider using technologies like
salted hashes to enhance security.
1. Biometric Authentication:
- Implement biometric authentication methods (e.g., fingerprint,
facial recognition) for enhanced security and user convenience.
3. **Adaptive Authentication:**
- Implement adaptive authentication mechanisms that adjust the
level of authentication based on contextual factors such as device,
location, and user behavior.
5. Session Management:
- Implement secure session management to protect against
session hijacking and session fixation attacks.
6. **Tokenization:**
- Use tokenization to replace sensitive data (such as passwords)
with unique tokens, reducing the risk associated with storing and
transmitting sensitive information.
7. **Continuous Monitoring:**
- Continuously monitor user activities and behavior to detect
anomalies and potential unauthorized access.
8. **Risk-Based Authentication:**
- Assess the risk level associated with each authentication attempt
and adjust the level of scrutiny accordingly.
9. **Mobile Authentication:**
- Leverage mobile device capabilities for authentication, such as
push notifications or one-time passcodes sent via SMS or mobile
apps.
Firewall
A firewall is a network security device, either hardware
or software-based, which monitors all incoming
and outgoing traffic and based on a defined set of
security rules it accepts, rejects or drops that specific
traffic.
Accept : allow the traffic
Reject : block the traffic but reply with an “unreachable
error”
Drop : block the traffic with no reply
A firewall establishes a barrier between secured internal
networks and outside untrusted network, such
as the Internet.
Types of Firewall
Firewalls are generally of two types: Host-based and
Network-based.
1. Host- based Firewalls : Host-based firewall is
installed on each network node which controls each
incoming and outgoing packet. It is a software
application or suite of applications, comes as a part of
the operating system. Host-based firewalls are needed
because network firewalls cannot provide protection
inside a trusted network. Host firewall protects each
host from attacks and unauthorized access.
2. Network-based Firewalls : Network firewall
function on network level. In other words, these
firewalls filter all incoming and outgoing traffic across
the network. It protects the internal network by filtering
the traffic using rules defined on the firewall. A
Network firewall might have two or more network
interface cards (NICs). A network-based firewall is
usually a dedicated system with proprietary software
installed.
Generation of Firewall
The term "socket" in SSL refers to the method of sending data via a network
between a client and a server.
Benefits of SSL:
o Data integrity: The data can't be tempered as it is not sent as a plain text, so
even if it is intercepted, it could not be decoded.
o Data privacy: The privacy of data is maintained using a series of protocols,
including the SSL Record Protocol, SSL Handshake Protocol, SSL Change CipherSpec
Protocol, and SSL Alert Protocol. So, confidential information, such as social security
number, credit card number, login details, can be transmitted securely.
o Client-server authentication: It uses the standard cryptographic technique to
authenticate the client and server.
PROXY
Proxy server refers to a server that acts as an intermediary between
the request made by clients, and a particular server for some services
or requests for some resources. There are different types of proxy
servers available that are put into use according to the purpose of a
request made by the clients to the servers. The basic purpose of Proxy
servers is to protect the direct connection of Internet clients and internet
resources. The proxy server also prevents the identification of the
client’s IP address when the client makes any request is made to any
other servers.
OR
The proxy server is a computer on the internet that accepts the
incoming requests from the client and forwards those requests to the
destination server. It works as a gateway between the end-user and the
internet. It has its own IP address. It separates the client system and web
server from the global network.
VPN creates tunnel between But proxy does not create tunnel
6. end users. between end users.
VPN offers high amount of Proxy does not offer any type of
7. security. security.
10. VPN encrypts the traffic. Proxy does not encrypt traffic.
Voice over Internet Protocol (VoIP)
Voice over Internet Protocol (VoIP) is a technology that allows
you to make voice calls using a broadband Internet connection
rather than an analogue (traditional) phone line. Some VoIP
services allow you to call multiple people at the same time,
while others may allow you to call anyone. They can have or not
have a phone number, which includes local, long-distance,
mobile, and international numbers. Some VoIP services require
you to use your computer or a special VoIP phone, whereas
others allow you to use a regular phone connected to a VoIP
adapter.
How VoIP/InternetVoice Works –
Voice is converted into a digital signal by VoIP services that travel over
the Internet. If the regular phone number is called, the signal is
converted to a regular telephone signal i.e. an analog signal before it
reaches the destination. VoIP can allow you to make a call directly from
a computer having a special VoIP phone, or a traditional phone
connected to a special adapter. Wireless hot spots in locations such as
airports, hospitals, cafes, etc allow you to connect to the Internet and
can enable you to use VoIP service wirelessly.
Advantages of VoIP –
1. Some VoIP services offer features and services that are not available with
a traditional phone, or are available but only for an additional fee.
2. Paying for both a broadband connection and a traditional telephone line
can be avoided.
3. Smoother connection than an analog signal can be provided.
Disadvantages of VoIP –
1. Some VoIP services don’t work during power outages and the service
provider may not offer backup power.
2. Not all VoIP services connect directly to emergency services through
emergency service numbers.
3. VoIP providers may or may not offer directory assistance.
Yes, high-speed
Internet requirement No, traditional phone line
broadband
Emergency services
May not connect directly Direct connection
access
Key Components
The key components of RTSP are −
Clients − Clients are typically media players or other software that sends
RTSP requests to servers in order to establish and control media sessions.
Servers − Servers are typically streaming media servers that receive RTSP
requests from clients and respond with session descriptions and other
information. They also stream the media to the client using the agreed-upon
transport protocol.
RTSP requests and responses − RTSP uses a set of requests and responses to
establish and control media sessions. Examples of RTSP requests include
"SETUP," "PLAY," and "TEARDOWN," and examples of RTSP responses
include "200 OK" and "404 Not Found."
Transport protocols − RTSP uses TCP (Transmission Control Protocol) as its
transport protocol for the exchange of RTSP requests and responses.
However, the actual media content is typically delivered using a separate,
UDP-based (User Datagram Protocol) protocol, such as Real-time Transport
Protocol (RTP).
Session descriptions − Session descriptions are used to communicate
information about the media being streamed, such as the media format, the
transport protocol to be used, and the location of the media. Session
descriptions are exchanged between the client and server during the setup of
a media session.
Media − The media being streamed is typically audio or video content,
although RTSP can also be used to stream other types of data. The media is
delivered to the client using the agreed-upon transport protocol.
What is the Real-time Transport Protocol (RTP)?
Real-time Transport Protocol (RTP) is a network protocol for the delivery of
audio and video over the internet. It is designed to provide end-to-end
network transport functions suitable for applications transmitting real-time
data, such as audio and video.
Applications of RTP :
1. RTP mainly helps in media mixing, sequencing and time-stamping.
2. Voice over Internet Protocol (VoIP)
3. Video Teleconferencing over Internet.
4. Internet Audio and video streaming.
JavaScript Cookies
A cookie is an amount of information that persists between a server-side
and a client-side. A web browser stores this information at the time of
browsing.
A cookie contains the information as a string generally in the form of a
name-value pair separated by semi-colons. It maintains the state of a
user and remembers the user's information among all the web pages.
1. document.cookie="name=value";
1. <!DOCTYPE html>
2. <html>
3. <head>
4. </head>
5. <body>
6. <input type="button" value="setCookie" onclick="setCookie()">
7. <input type="button" value="getCookie" onclick="getCookie()">
8. <script>
9. function setCookie()
10. {
11. document.cookie="username=Duke Martin";
12. }
13. function getCookie()
14. {
15. if(document.cookie.length!=0)
16. {
17. alert(document.cookie);
18. }
19. else
20. {
21. alert("Cookie not available");
22. }
23. }
24. </script>
25.
26. </body>
27. </html>
Example 2
HTML
<!DOCTYPE html>
<html>
<body>
<form name="myform" action="">
Enter name:
onclick="WriteCookie();" />
</form>
<script type="text/javascript">
function WriteCookie() {
if (document.myform.customer.value == "") {
return;
cookievalue = escape(
document.myform.customer.value) + ";";
+ "name=" + cookievalue);
}
</script>
</body>
</html
Output:
Adding an expiry date (in UTC): We can add expire date for the cookie to
ensure that after that time the cookie will no longer be in use.
Syntax:
document.cookie = "username=geeksforgeeks;
expires=Sun, 16 JAN 2022 12:00:00 UTC";
Deleting the Cookie: When you want to delete the cookie just simply set the
expires parameter and leave the username blank.
document.cookie = "username=;
expires=Sun, 16 JAN 2022 12:00:00 UTC";
<!DOCTYPE html>
<html>
<head>
</head>
"C:/Users/dharam/Desktop/attr1.png" />
"C:/Users/dharam/Desktop/gradient3.png" />
"C:/Users/dharam/Desktop/col_last.png" />
<noframes>
</noframes>
</frameset>
</html>
<!DOCTYPE html>
<html>
<head>
</head>
"C:/Users/dharam/Desktop/gradient3.png" />
"C:/Users/dharam/Desktop/col_last.png" />
<noframes>
</noframes>
</frameset>
</html>
Output: The above example basically used to create three vertical frames:
left, center and right using col attribute of frameset tag.
What is Script?
Scripting language can be classified into two main categories that are as
follows:
Client-side script
Server-side script
On a dynamic website or webpage, both client-side and server-side scripts
are involved. Client-side and server-side are sometimes known as front-end
and back-end.
Dynamic Web Pages: Dynamic Web Pages are written in languages such as CGI,
AJAX, ASP, ASP.NET, etc. In dynamic web pages, the Content of pages is
different for different visitors. It takes more time to load than the static web
page. Dynamic web pages are used where the information is changed frequently, for
example, stock prices, weather information, etc.
Difference between Static and Dynamic Web Pages:
SL.N
O Static Web Page Dynamic Web Page
In static web pages, Information are In dynamic web page, Information are
3.
change rarely. change frequently.
Static Web Page takes less time for Dynamic web page takes more time
4.
loading than dynamic web page. for loading.
Static web pages are written in Dynamic web pages are written in
6. languages such as: HTML, languages such as: CGI, AJAX, ASP,
JavaScript, CSS, etc. ASP.NET, etc.
Note: We can create a list inside another list, which will be termed as nested List.
1. <ol>
2. <li>Aries</li>
3. <li>Bingo</li>
4. <li>Leo</li>
5. <li>Oracle</li>
6. </ol>
Output:
1. Aries
2. Bingo
3. Leo
4. Oracle
Click here for full details of HTML ordered list. HTML Ordered List
1. <ul>
2. <li>Aries</li>
3. <li>Bingo</li>
4. <li>Leo</li>
5. <li>Oracle</li>
6. </ul>
Output:
o Aries
o Bingo
o Leo
o Oracle
Click here for full details of HTML unordered list. HTML Unordered List
The definition list is very appropriate when you want to present glossary, list of terms
or other name-value list.
1. <dl>
2. <dt>Aries</dt>
3. <dd>-One of the 12 horoscope sign.</dd>
4. <dt>Bingo</dt>
5. <dd>-One of my evening snacks</dd>
6. <dt>Leo</dt>
7. <dd>-It is also an one of the 12 horoscope sign.</dd>
8. <dt>Oracle</dt>
9. <dd>-It is a multinational technology corporation.</dd>
10. </dl>
Output:
Aries
Bingo
Leo
Oracle
In HTML, both Id and Class are the element selector and are used to identify
an element based on the name assign to these parameters. ID and Class
selectors are the most widely used element selectors in CSS (HTML). The
basic difference between ID and Class is that the ID selector is applied only
to one element in a page, whereas the class selector can be applied to
several elements on a single page.
Read this article to find out more about "id" and "class" in HTML and how
they are different from each other.
What is ID in HTML?
In HTML, the "id" selector is used id attribute of an element. For an HTML
element, the "id" name starts with the symbol '#' followed by a unique
name. One important characteristics of the id element is that we can only
attach one id selector to an element. Hence, the ID selector is always unique
within an HTML page.
Example of ID Selector
<!DOCTYPE html>
<html>
<head>
<title>
Id demo
</title>
<style>
#idDemo{
color:green;
font-size:25px;
}
</style>
</head>
<body style="text-align:center">
<h1>Get element by Id</h1>
<p id="idDemo">Demo for Id selector</p>
</body>
</html>
Id Class
1. In HTML, for an element, the ID name starts with the "class" assigned to an element has its name sta
"#" symbol followed by a unique name assigned to it. followed by class name.
2. Only one ID selector can be attached to an element. Multiple class selectors can be attached to an e
3. ID is unique in a page and can only apply to at most The class can be applied to multiple elements s
one element multiple times on a single page.
The following are the important differences between Id and Class & minius;
HTTP GET: The Hypertext Transfer Protocol(HTTP) Get method is mainly used at
the client (Browser) side to send a request to a specified server to get certain data or
resources. Using this method the server should only let us receive the data and not
change its state. Hence it is only used to view something and not to change it. Get
method is one of the most used HTTP method. The request parameter of the get
method is appended to the URL. Get request is better for the data which does not need
to be secure (It means the data which does not contain images or word documents).
Example: In the following HTML code we have created a form with text field as
Username and City. we have also included a PHP file getmethod.php where our data
would be sent after we click the submit button.
index.html
<!DOCTYPE html>
<html>
<body>
</form>
</body>
</html>
In the following PHP code using the GET method we have displayed the Username
and city.
getmethod.php
<!DOCTYPE html>
<html>
<body>
Welcome
</body>
</html>
Output: Data passed in GET method is clearly visible in the address bar, which can
compromise the security.
HTTP POST: The Hypertext Transfer Protocol(HTTP) Post method is mainly used at
the client (Browser) side to send data to a Specified server in order to create or rewrite
a particular resource/data. This data sent to the server is stored in the request body of
the HTTP request. Post method eventually leads to the creation of a new resource or
updating an existing one. Due to this dynamic use, it is one of the most used HTTP
methods. It is not one of the most secure methods because the data that is been sent is
included in the body of the request and not in the URL. Post request is better for the
data which needs to be secure (It means the data which contains images or word
documents).
Example: In the following HTML code we have created a form with text field as
Username and Area of study. we have also included a PHP file postmethod.php,
where our data would be sent after we click the submit button.
index.html
<!DOCTYPE html>
<html>
<body>
</form>
</body>
</html>
In the following PHP code using the POST method we have displayed the Username
and Area of study .
postmethod.php
<!DOCTYPE html>
<html>
<body>
Welcome
</body>
</html>
Output: Data passed in POST method is not shown in the address bar, which
maintains the security.
In GET method we can not send large In POST method large amount of data
amount of data rather limited data is sent can be sent because the request
because the request parameter is appended parameter is appended into the
into the URL. body.
GET request is comparatively better than POST request is comparatively less
Post so it is used more than the better than Get so it is used less than
Post request. the Get request.
Request made through GET method are Request made through POST method
stored in Browser history. is not stored in Browser history.
GET method request can be saved as POST method request can not be
bookmark in browser. saved as bookmark in browser.
Data passed through GET method can be Data passed through POST method
easily stolen by attackers. can not be easily stolen by attackers.
In GET method only ASCII characters are In POST method all types of data is
allowed. allowed.
Cookie Session
Cookies end on the lifetime set by When the user quits the browser or logs out of
the user. the programmed, the session is over.
Cookies stored data in text file. Session save data in encrypted form.
HTML vs XML
HTML: HTML (Hyper Text Markup Language) is used to create web pages and
web applications. It is a markup language. By HTML we can create our own static
page. It is used for displaying the data not to transport the data. HTML is the
combination of Hypertext and Markup language. Hypertext defines the link between
the web pages. A markup language is used to define the text document within tag
which defines the structure of web pages. This language is used to annotate (make
notes for the computer) text so that a machine can understand it and manipulate text
accordingly.
Example:
html
<!DOCTYPE html>
<html>
<head>
<title>GeeksforGeeks</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
</body>
</html>
Output:
<name>G4G</name>
<College>Geeksforgeeks</College>
<mobile>2345456767</mobile>
</address>
</contactinfo>
Output:
G4G
Geeksforgeeks
2345456767
Difference between HTML and XML: There are many differences
between HTML and XML. These important differences are given below:
HTML XML
HTML stands for Hyper Text Markup XML stands for Extensible Markup
2.
Language. Language.
7. HTML can ignore small errors. XML does not allow errors.
10
HTML tags are predefined tags. XML tags are user-defined tags.
.
13 HTML tags are used for displaying XML tags are used for describing the
. the data. data not for displaying.
15
HTML is used to display the data. XML is used to store data.
.
16 HTML does not carry data it just XML carries the data to and from the
. displays it. database.
1. Local variable
2. Global variable
3. Static variable
Local variable
The variables that are declared within a function are called local variables
for that function. These local variables have their scope only in that
particular function in which they are declared. This means that these
variables cannot be accessed outside the function, as they have local
scope.
A variable declaration outside the function with the same name is
completely different from the variable declared inside the function. Let's
understand the local variables with the help of an example:
File: local_variable1.php
1. <?php
2. function local_var()
3. {
4. $num = 45; //local variable
5. echo "Local variable declared inside the function is: ". $num;
6. }
7. local_var();
8. ?>
Output:
File: local_variable2.php
1. <?php
2. function mytest()
3. {
4. $lang = "PHP";
5. echo "Web development language: " .$lang;
6. }
7. mytest();
8. //using $lang (local variable) outside the function will generate an error
9. echo $lang;
10. ?>
Output:
Global variable
The global variables are the variables that are declared outside the
function. These variables can be accessed anywhere in the program. To
access the global variable within a function, use the GLOBAL keyword
before the variable. However, these variables can be directly accessed or
used outside the function without any keyword. Therefore there is no
need to use any keyword to access a global variable outside the function.
Example:
File: global_variable1.php
1. <?php
2. $name = "Sanaya Sharma"; //Global Variable
3. function global_var()
4. {
5. global $name;
6. echo "Variable inside the function: ". $name;
7. echo "</br>";
8. }
9. global_var();
10. echo "Variable outside the function: ". $name;
11. ?>
Output:
Example:
File: global_variable2.php
1. <?php
2. $name = "Sanaya Sharma"; //global variable
3. function global_var()
4. {
5. echo "Variable inside the function: ". $name;
6. echo "</br>";
7. }
8. global_var();
9. ?>
Output:
Example:
File: global_variable3.php
1. <?php
2. $num1 = 5; //global variable
3. $num2 = 13; //global variable
4. function global_var()
5. {
6. $sum = $GLOBALS['num1'] + $GLOBALS['num2'];
7. echo "Sum of global variables is: " .$sum;
8. }
9. global_var();
10. ?>
Output:
If two variables, local and global, have the same name, then the local variable has
higher priority than the global variable inside the function.
Example:
File: global_variable2.php
1. <?php
2. $x = 5;
3. function mytest()
4. {
5. $x = 7;
6. echo "value of x: " .$x;
7. }
8. mytest();
9. ?>
Output:
Value of x: 7
Note: local variable has higher priority than the global variable.
What is an Array?
An array is a special variable, which can hold
more than one value at a time.
An array can hold many values under a single
name, and you can access the values by
referring to an index number.
array();
In PHP, there are three types of arrays:
<!DOCTYPE html>
<html>
<body>
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " .
$cars[2] . ".";
?>
</body>
</html>
Get The Length of an Array - The count()
Function
The count() function is used to return the length
(the number of elements) of an array:
<!DOCTYPE html>
<html>
<body>
<?php
$cars = array("Volvo", "BMW", "Toyota");
echo count($cars);
?>
</body>
</html>
</body>
</html>
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.
<?php
$cookie_name = "user";
$cookie_value = "John Doe";
setcookie($cookie_name, $cookie_value, time()
What is an Exception
With PHP 5 came a new object oriented way of dealing with
errors.
<?php
//create function with an exception
function checkNum($number) {
if($number>1) {
throw new Exception("Value must be 1 or below");
}
return true;
}
//trigger exception in a "try" block
try {
checkNum(2);
//If the exception is thrown, this text will not be shown
echo 'If you see this, the number is 1 or below';
}
//catch exception
catch(Exception $e) {
echo 'Message: ' .$e->getMessage();
}
?>