0% found this document useful (0 votes)
24 views33 pages

Iwt Assignment

CSS3 introduced many new features to create more dynamic and visually appealing websites, including new selectors for targeting elements, improved box model controls, text effects, gradients, transformations, transitions, animations, multiple backgrounds, media queries, and flexible box and grid layouts. CSS functions allow for dynamic styling by taking parameters and returning computed values.

Uploaded by

Piyush Kaithwas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
24 views33 pages

Iwt Assignment

CSS3 introduced many new features to create more dynamic and visually appealing websites, including new selectors for targeting elements, improved box model controls, text effects, gradients, transformations, transitions, animations, multiple backgrounds, media queries, and flexible box and grid layouts. CSS functions allow for dynamic styling by taking parameters and returning computed values.

Uploaded by

Piyush Kaithwas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 33

Question 1 features of css 3

CSS3, or Cascading Style Sheets 3, introduced a variety of new features and


enhancements for web designers and developers to create more dynamic and visually
appealing websites. Here are some of the key features of CSS3:

1. Selectors: CSS3 introduced new and advanced selectors, such as attribute selectors,
structural pseudo-classes, and more, which allow for more precise targeting of HTML
elements.
2. Box Model: Improved control over the box model with properties like box-sizing,
which lets you specify how an element's width and height should be calculated.
3. Text Effects: CSS3 allows for the creation of attractive text effects using properties like
text-shadow, text-overflow, and word-wrap.
4. Gradients: You can create gradient backgrounds and text using the linear-gradient
and radial-gradient properties, eliminating the need for image-based gradients.
5. Transformations: CSS3 enables 2D and 3D transformations of elements with properties
like transform, rotate, scale, and perspective, making it possible to create
animations and interactive elements.
6. Transitions: With CSS3 transitions, you can smoothly animate property changes over
time, giving a more polished feel to your web elements.
7. Animations: CSS3 animations allow you to create complex animations using keyframes,
easing functions, and more, without the need for JavaScript or Flash.
8. Multiple Backgrounds: You can apply multiple background images to an element and
control their positioning and stacking order with properties like background-image and
background-size.
9. Media Queries: CSS3 introduced media queries, which enable responsive web design
by allowing styles to be applied based on the characteristics of the viewing device, such
as screen size and orientation.
10. Flexbox: The Flexbox layout model is a powerful feature of CSS3 that simplifies the
design of complex layouts and the alignment of elements within a container.
11. Grid Layout: CSS Grid Layout allows for the creation of grid-based layouts, offering
precise control over the placement and alignment of elements within a grid.
12. Custom Fonts: With CSS3's @font-face rule, you can use custom web fonts, providing
more flexibility in typography choices.
13. Border-radius: The border-radius property enables the creation of rounded corners
on elements, adding visual appeal to various design elements.
14. Opacity: CSS3 introduced the opacity property, allowing you to control the
transparency of elements without affecting their content.
15. Shadows: You can create drop shadows and box shadows using properties like box-
shadow and text-shadow to add depth and dimension to elements.
16. RGBA and HSLA: CSS3 supports color specifications in RGBA (red, green, blue, alpha)
and HSLA (hue, saturation, lightness, alpha) formats, providing transparency options for
colors.
17. Filters: You can apply various visual effects to elements using CSS3 filters, including
blur, grayscale, and more.
18. Calculation: The calc() function allows for mathematical calculations within CSS
property values, making it easier to create dynamic layouts.

These features, among others, have significantly improved the capabilities of CSS for
web design, enabling designers and developers to create more engaging and
responsive web experiences.

i.) Classes in CSS


In CSS (Cascading Style Sheets), classes are a way to define and apply styles to
HTML elements. Classes allow you to group multiple HTML elements together and apply
the same styling to them, which can help maintain a consistent and organized design for
your web pages. Here's how you can work with classes in CSS:

1. Defining a Class: To define a class in CSS, you use a period (.) followed by the class
name. For example:
.my-class {
/* CSS rules go here */
}
2. Applying a Class: To apply a class to an HTML element, you use the class attribute
within the HTML tag. For example:
<p class="my-class">This is a paragraph with a custom class.</p>
3. Styling with Classes: Within the class definition, you can specify various CSS properties
and values to style the elements with that class. For example:
. my-class {
font-size: 16px;
color: #333;
background-color: #f0f0f0;
padding: 10px;
}
4. Multiple Classes: You can apply multiple classes to a single HTML element by
separating them with a space. This allows you to combine styles from different
classes. For example:
<div class="class1 class2">This element has multiple classes.</div> > This element
has multiple classes. </div>
5. Cascading and Specificity: CSS follows a cascading order of specificity, meaning that if
there are conflicting styles, the more specific rule takes precedence. Classes are less
specific than IDs and inline styles, but more specific than element selectors.
6. Reusability: One of the main advantages of using classes is reusability. You can apply
the same class to multiple elements, making it easy to maintain a consistent design
throughout your website.

Here's an example of how classes are used in HTML and CSS:

htmlCopy code

<!DOCTYPE html>
<html>
<head>
<style>
.my-class {
font-size: 18px;
color: blue;
}
</style>
</head>
<body>
<h1 class="my-class">This is a heading with the class 'my-class'.</h1>
<p class="my-class">This is a paragraph with the same class.</p>
</body>
</html>
In this example, both the heading and the paragraph share the same styling defined by
the "my-class" class in the CSS, illustrating how classes can be used for consistent styling
across multiple elements.

3) Back ground properties of CSS.

Cascading Style Sheets (CSS) is a stylesheet language used for describing the
presentation and formatting of a document written in HTML or XML. It allows web
developers to control the visual appearance of web pages. Here are some background
properties and concepts related to CSS:

1. Cascading: The "C" in CSS stands for "Cascading," which signifies the order of
importance and specificity in styling rules. CSS rules can be defined in multiple places,
such as inline styles, external stylesheets, and browser defaults. The cascade determines
which rule takes precedence when there are conflicting styles.
2. Selectors: Selectors are patterns used to select HTML elements to which you want to
apply CSS styles. Common selectors include element selectors (e.g., p, h1), class
selectors (e.g., .button), and ID selectors (e.g., #header).
3. Properties: CSS properties are the attributes you want to style, such as color, font-
size, margin, and background-color. Each property has a name and a value, which
determines how the element is displayed.
4. Values: Values are specific settings for CSS properties. For example, you can set the
color property to values like "red," "#00ff00" (a hexadecimal color), or "rgb(255, 0, 0)"
(an RGB color).
5. Declaration: A declaration consists of a CSS property and its corresponding value. It is
usually enclosed in curly braces and separated by a colon. For example:
font-size: 16px;
6. Selectors and Declarations in Rules: CSS rules are made up of selectors and
declarations. For instance

h1 {

color: blue;

}
}
7. External Stylesheets: External CSS files are separate documents with a .css extension.
They are linked to HTML documents using the <link> element in the document's
<head> section.
8. Inline Styles: Inline styles are CSS styles applied directly to an HTML element within its
style attribute. They have the highest specificity.
9. Internal Stylesheets: Internal styles are defined within the <style> element in the
HTML document's <head>. They apply to that specific HTML document only.
10. Selectors Specificity: Specificity refers to the order of importance of selectors. It
determines which style rules will be applied if there are conflicting rules. Inline styles
have the highest specificity, followed by IDs, classes, and element selectors.
11. Inheritance: Some CSS properties are inherited from parent elements to their child
elements. For example, if you set a font style on a parent element, it may affect the text
within its child elements.
12. Box Model: The box model is a fundamental concept in CSS, where each HTML element
is considered a box with content, padding, borders, and margins. You can style these
aspects to control the element's layout and appearance.
13. Responsive Design: CSS is often used to create responsive web designs that adapt to
different screen sizes and devices. Techniques like media queries allow you to apply
different styles based on the device's characteristics.
4) Functions

Functions in CSS, when mentioned in web development, are often referring to CSS
functions or expressions that allow for dynamic styling and customization of web
elements. Here's an explanation in English:

In CSS (Cascading Style Sheets), functions are special constructs that enable us to apply
dynamic styling to web elements. They are used to calculate values or manipulate
properties based on specific conditions, user interactions, or other factors. CSS functions
are like mathematical functions, taking one or more input parameters and returning a
computed value.

Some common CSS functions include:

1. calc(): This function is used for performing arithmetic operations within CSS property
values. It allows you to combine different units, percentages, and values to create
dynamic styles.
width:
calc(50% - 20px);

2. var(): The var() function is used to define and apply custom CSS variables (or custom
properties). It allows you to set values in one place and use them throughout your
stylesheet, making it easier to maintain and update styles.
:root {
--main-color: #3498db;
}

.button {
background-color: var(--main-color);
}
3. min(), max(), clamp(): These functions are used to set responsive styles based on the
viewport size or other conditions. They help ensure that your design remains flexible
and adapts to different screen sizes.
font-size: min(2rem, 5vw);

attr() Returns the value of an attribute of the selected element


4) Form validation

Form validation in JavaScript and HTML is an essential aspect of web development to ensure
that user-submitted data is accurate and meets the required criteria. Below is an example of how
to perform basic form validation using HTML and JavaScript.

<!DOCTYPE html>

<html>

<head>

<title>Form Validation</title>

<script>

function validateForm() {

var name = document.forms["myForm"]["name"].value;

var email = document.forms["myForm"]["email"].value;

var password = document.forms["myForm"]["password"].value;

if (name === "") {

alert("Name must be filled out");

return false;

if (email === "") {

alert("Email must be filled out");

return false;

} else {

var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

if (!email.match(emailPattern)) {

alert("Please enter a valid email address");

return false;

}
}

if (password === "") {

alert("Password must be filled out");

return false;

} else if (password.length < 6) {

alert("Password must be at least 6 characters long");

return false;

</script>

</head>

<body>

<h2>Form Validation Example</h2>

<form name="myForm" onsubmit="return validateForm()" method="post">

<label for="name">Name:</label>

<input type="text" id="name" name="name"><br><br>

<label for="email">Email:</label>

<input type="text" id="email" name="email"><br><br>

<label for="password">Password:</label>

<input type="password" id="password" name="password"><br><br>

<input type="submit" value="Submit">

</form>

</body>

</html>
2. What is DOM? What is its role in DHTML?

The Document Object Model (DOM) is a programming


interface for HTML(HyperText Markup Language) and XML(Extensible
markup language) documents. It defines the logical structure of documents and
the way a document is accessed and manipulated.
Note: It is called a Logical structure because DOM doesn’t specify any
relationship between objects.
DOM is a way to represent the webpage in a structured hierarchical way so that
it will become easier for programmers and users to glide through the document.
With DOM, we can easily access and manipulate tags, IDs, classes, Attributes,
or Elements of HTML using commands or methods provided by the Document
object. Using DOM, the JavaScript gets access to HTML as well as CSS of the
web page and can also add behavior to the HTML elements. so
basically Document Object Model is an API that represents and interacts
with HTML or XML documents.

Levels of DOM:
 Level 0: Provides a low-level set of interfaces.
 Level 1: DOM level 1 can be described in two parts: CORE and HTML.
 CORE provides low-level interfaces that can be used to represent
any structured document.
 HTML provides high-level interfaces that can be used to represent
HTML documents.
 Level 2: consists of six
specifications: CORE2, VIEWS, EVENTS, STYLE, TRAVERSAL,
and RANGE.
 CORE2: extends the functionality of CORE specified by DOM level
1.
 VIEWS: views allows programs to dynamically access and
manipulate the content of the document.
 EVENTS: Events are scripts that are either executed by the
browser when the user reacts to the web page.
 STYLE: allows programs to dynamically access and manipulate the
content of style sheets.
 TRAVERSAL: This allows programs to dynamically traverse the
document.
 RANGE: This allows programs to dynamically identify a range of
content in the document.
 Level 3: consists of five different specifications: CORE3, LOAD and
SAVE, VALIDATION, EVENTS, and XPATH.
 CORE3: extends the functionality of CORE specified by DOM level
2.
 LOAD and SAVE: This allows the program to dynamically load the
content of the XML document into the DOM document and save the
DOM Document into an XML document by serialization.
 VALIDATION: This allows the program to dynamically update the
content and structure of the document while ensuring the document
remains valid.
 EVENTS: extends the functionality of Events specified by DOM
Level 2.
 XPATH: XPATH is a path language that can be used to access the
DOM tree

The main roles of the DOM in DHTML are:

1. Structured Representation: The DOM represents the elements and content of a web
page in a structured format, where each element is treated as an object, and they are
organized hierarchically. This structure allows web developers to access and manipulate
the content and structure of a web page using programming languages like JavaScript.
2. Dynamic Content Manipulation: With the DOM, developers can dynamically update,
add, or remove content from a web page without requiring a full page reload. This
enables the creation of interactive and responsive web applications. For example, you
can change the text or attributes of HTML elements, create new elements on the fly, or
remove elements from the document.
3. Event Handling: The DOM provides a mechanism for handling events like user
interactions (e.g., mouse clicks, keyboard input) or changes in the document (e.g.,
element load or change). This allows developers to define how the web page responds
to user actions and other events.
4. Cross-Browser Compatibility: The DOM standardizes the way web pages are accessed
and manipulated across different web browsers. This helps ensure that DHTML scripts
work consistently on various browsers, reducing compatibility issues.

3. How to use Email validation in Java Script? Like user in can’t enter invalid email
address. Write Java Script code.
You can use JavaScript to perform email validation by checking if a given email address
conforms to a valid email format. JavaScript doesn't provide built-in email validation, but
you can achieve this using regular expressions. Here's a simple example of how to do it:

function isValidEmail(email) {
// Regular expression for a basic email validation
var emailPattern = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;

return emailPattern.test(email);
}

var userEmail = "user@example.com"; // Replace this with the email you want to validate
if (isValidEmail(userEmail)) {
console.log("Valid email address");
} else {
console.log("Invalid email address");
}

In this code, we define a isValidEmail function that uses a regular expression


(emailPattern) to check if the provided email address is valid. The regular expression
checks for the following basic criteria:

1. One or more characters before the "@" symbol.


2. The "@" symbol.
3. One or more characters between the "@" symbol and the dot (.) in the domain.
4. The dot (.) in the domain.
5. Two or more characters after the dot in the domain (e.g., ".com").

You can adjust the regular expression to fit your specific email validation requirements.
This is a basic example, and email validation can be quite complex, but this should work
for most common cases.
Remember to replace "user@example.com" with the email address you want to validate.
The code will return true if the email is valid and false if it's not.

4. Explain the different components of DTD with example.

This chapter will discuss about XML Components from DTD


perspective. A DTD will basically contain declarations of the
following XML components −

 Element
 Attributes
 Entities

Elements
XML elements can be defined as building blocks of an XML
document. Elements can behave as a container to hold text,
elements, attributes, media objects or mix of all.

Each XML document contains one or more elements, the boundaries


of which are either delimited by start-tags and end-tags, or empty
elements.

Example

Below is a simple example of XML elements

<name>
Tutorials Point
</name>

As you can see we have defined a <name> tag. There's a text


between start and end tag of <name>. Elements, when used in an
XML-DTD, need to be declared which will be discussed in detail in
the chapter DTD Elements.
Attributes
Attributes are part of the XML elements. An element can have any
number of unique attributes. Attributes give more information about
the XML element or more precisely it defines a property of the
element. An XML attribute is always a name-value pair.

Example

Below is a simple example of XML attributes −

<img src = "flower.jpg"/>

Here img is the element name whereas src is an attribute name


and flower.jpg is a value given for the attribute src.

If attributes are used in an XML DTD then these need to be declared


which will be discussed in detail in the chapter DTD Attributes

Entities
Entities are placeholders in XML. These can be declared in the
document prolog or in a DTD. Entities can be primarily categorized
as −

 Built-in entities
 Character entities
 General entities
 Parameter entities

There are five built-in entities that play in well-formed XML, they
are −

 ampersand: &amp;
 Single quote: &apos;
 Greater than: &gt;
 Less than: &lt;
 Double quote: &quot;
5. What is XML and attributes of XML?

 XML stands for eXtensible Markup Language


 XML is a markup language much like HTML
 XML was designed to store and transport data
 XML was designed to be self-descriptive
 XML is a W3C Recommendation

XML, or Extensible Markup Language, is a markup language that is designed to store


and transport data. It is a simple and flexible text-based format that is both human-
readable and machine-readable. XML is often used to represent structured data in a way
that is both platform-independent and self-descriptive. Here are some of the key
attributes of XML:

1. Extensibility: XML is "extensible" because it allows users to define their own elements
and tags, making it adaptable to a wide range of applications. This extensibility is one of
its defining features, and it allows for the creation of custom data structures.
2. Hierarchy: XML data is organized in a hierarchical tree-like structure. It consists of
elements, which can contain other elements, creating a clear parent-child relationship.
This hierarchical structure is conducive to representing structured data.
3. Self-Descriptive: XML documents are self-descriptive, meaning they include
information about the data they contain. Each element is typically labeled with a start
tag and an end tag that specify its name. Additionally, attributes can be used to provide
metadata or additional information about elements.
4. Tags: XML uses tags to define elements. An element is enclosed within a pair of angle
brackets, such as <element>. The start tag opens the element, and the end tag closes it,
e.g., </element>. Elements can be nested within other elements.
5. Attributes: XML elements can have attributes associated with them. Attributes provide
additional information about the element. They are defined within the start tag of an
element and consist of a name and a value, separated by an equals sign. For example:
<book title="Introduction to XML" author="John Doe">

6. Well-Formed: XML documents must adhere to specific syntax rules to be considered


well-formed. This includes having a single root element, properly nested elements,
closed tags, and correct attribute formatting. A well-formed XML document can be
parsed and processed by XML parsers.
7. Case Sensitivity: XML is case-sensitive, meaning that elements, tags, and attribute
names are distinguished by their case. For example, <book> and <Book> are treated as
different elements.
8. Unicode Support: XML supports a wide range of character encodings, making it
suitable for internationalization and the representation of various languages and special
characters.
9. Metadata: XML can be used to store metadata and structured information, making it a
common choice for data exchange formats, configuration files, and more.
10. Parsing: To work with XML data, you typically use XML parsers, which can parse and
extract data from XML documents. These parsers can be found in various programming
languages and are used to navigate and manipulate XML content.

XML is widely used in various domains, including web services (SOAP and REST),
configuration files, data interchange, and more, due to its versatility and platform-
agnostic nature.

6. Explain the concept of object oriented programming with PHP.

We can imagine our universe made of different objects like sun,


earth, moon etc. Similarly we can imagine our car made of different
objects like wheel, steering, gear etc. Same way there is object
oriented programming concepts which assume everything as an
object and implement a software using different objects.

Object Oriented Concepts


Before we go in detail, lets define important terms related to Object
Oriented Programming.

 Class − This is a programmer-defined data type, which includes


local functions as well as local data. You can think of a class as
a template for making many instances of the same kind (or
class) of object.
 Object − An individual instance of the data structure defined by
a class. You define a class once and then make many objects
that belong to it. Objects are also known as instance.
 Member Variable − These are the variables defined inside a
class. This data will be invisible to the outside of the class and
can be accessed via member functions. These variables are
called attribute of the object once an object is created.
 Member function − These are the function defined inside a class
and are used to access object data.
 Inheritance − When a class is defined by inheriting existing
function of a parent class then it is called inheritance. Here
child class will inherit all or few member functions and
variables of a parent class.
 Parent class − A class that is inherited from by another class.
This is also called a base class or super class.
 Child Class − A class that inherits from another class. This is
also called a subclass or derived class.
 Polymorphism − This is an object oriented concept where same
function can be used for different purposes. For example
function name will remain same but it take different number of
arguments and can do different task.
 Overloading − a type of polymorphism in which some or all of
operators have different implementations depending on the
types of their arguments. Similarly functions can also be
overloaded with different implementation.
 Data Abstraction − Any representation of data in which the
implementation details are hidden (abstracted).
 Encapsulation − refers to a concept where we encapsulate all
the data and member functions together to form an object.
 Constructor − refers to a special type of function which will be
called automatically whenever there is an object formation
from a class.
 Destructor − refers to a special type of function which will be
called automatically whenever an object is deleted or goes out
of scope.

7. Write about cookies & sessions in php with suitable program.

Cookies and sessions are essential components in web development, particularly when
working with PHP, to maintain and manage user data and state throughout a user's
interaction with a website or web application. Let's discuss both concepts and provide a
simple PHP program to demonstrate their usage.
Cookies: Cookies are small pieces of data stored on the user's browser. They are often
used to store user-specific information such as preferences or shopping cart contents.
Cookies are sent with every HTTP request, allowing the server to recognize the user and
provide a personalized experience.

Sessions: Sessions, on the other hand, are used to store user data on the server-side. A
unique session identifier is stored as a cookie on the user's browser, and the
corresponding data is stored on the server. This allows for secure storage of sensitive
information and user states

<?php
session_start();

echo "Your favorite color is: " . $_SESSION['favorite_color'];


?>

Output:
If you refresh the page or navigate to a different page and run the script again,
it will show the following
Your favorite color is:blue
Your favorite color is: blue

<?php

// 86400 = 1 day

setcookie('favorite_color', 'blue', time() + (86400 * 30));

echo "Cookie is set.";

?>

Output:
The first time you run the script, it will show

Cookie is set
8. Write short note on radio buttons and check boxes object in Java Script.

Radio button: It is generally used in HTML forms. HTML forms are required
when you need to collect some data from the site visitors. A radio button is used
when you want to select only one option out of several available options.
Example:
<html>

<head>

<title>

Radio Button

<title>

</head>

<body>

<form>

Do you agree this statement?

<br>

<input type="radio"

name="agree"

value="yes">Yes

<br>

<input type="radio"

name="agree"

value="no">No

<br>

<input type="Submit">

</form> </body>

</html>
Checkbox: Checkboxes are also mostly used in HTML forms. A checkbox
allows you to choose one or many options to be selected from a list of
options.
Example:
<html>

<head>

<title>

HTML Checkbox

<title>

</head>

<body>

<form>

Choose languages you know:

<br>

<input type="checkbox"

name="C"

value="yes">C

<br>

<input type="checkbox"

name="C++"

value="yes">C++

<br>

<input type="checkbox"

name="Java"

value="yes">Java

<br>

<input type="checkbox"

name="Python"
value="yes">Python

<br>

<input type="Submit">

</form>

</body>

</html>

9. Explain PHPmyadmin, and briefly explain database bugs

phpMyAdmin:

phpMyAdmin is a free and open-source web-based application written in PHP that


provides a graphical user interface (GUI) for managing and interacting with MySQL and
MariaDB databases. It is a powerful tool for database administrators, developers, and
website owners to perform various tasks related to database management. Some of the
key features of phpMyAdmin include:

1. Database Creation: Users can create new databases through the GUI.
2. Table Management: It allows users to create, modify, and delete database tables.
3. Data Entry and Editing: You can easily insert, update, and delete data in your database
tables.
4. SQL Query Execution: phpMyAdmin enables users to run SQL queries directly, making
it a valuable tool for database administrators and developers.
5. User Privilege Management: It helps in setting up user accounts and managing their
privileges, ensuring database security.
6. Import and Export Data: You can import data from various file formats (e.g., SQL, CSV)
and export data in different formats as well.
7. Server Status: Provides information about the server's health, performance, and
configuration.
8. Database Maintenance: It includes tools for optimizing, repairing, and analyzing
databases.

Database Bugs:
Database bugs refer to software defects or issues within a database management
system that can impact its functionality, data integrity, or security. These bugs can arise
from various sources, such as coding errors, software updates, hardware failures, or data
corruption. Here are some common types of database bugs:

1. Data Corruption: This bug occurs when data stored in the database becomes corrupt
due to various reasons, such as hardware failures, software errors, or incomplete
transactions. It can lead to data loss and incorrect query results.
2. Performance Issues: Performance-related bugs can cause slow query execution,
excessive resource usage, and bottlenecks in the database system. These issues may
result from inefficient query optimization, indexing problems, or hardware limitations.
3. Concurrency Problems: Concurrency bugs can lead to issues such as data inconsistency
when multiple users or applications access the database simultaneously. Problems like
deadlocks or race conditions can hinder proper data manipulation.
4. Security Vulnerabilities: Database bugs can also introduce security vulnerabilities.
These may allow unauthorized access, data leaks, or other malicious activities,
compromising the confidentiality and integrity of the data.
5. SQL Injection: SQL injection is a common type of bug where attackers exploit poorly
sanitized inputs to execute arbitrary SQL queries. This can lead to unauthorized data
access or modification.
6. Software Bugs: Bugs in the database management system's software can lead to issues
like crashes, incorrect results, or unexpected behavior. These bugs may arise from
coding errors, logic flaws, or software updates.
7. Data Loss: Data loss bugs can result in the accidental deletion or corruption of data due
to software or human errors. Regular backups are essential to mitigate the impact of
such bugs.

To address and prevent these database bugs, developers, administrators, and users
need to implement best practices for database management, perform thorough testing,
and keep their database management system and software up to date with the latest
patches and security measures. Regular monitoring and maintenance are also critical for
identifying and addressing potential issues before they lead to significant problems.

10. Differentiate HTML and XML.

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:
<!DOCTYPE html>
<html>
<head>
<title>GeeksforGeeks</title>
</head>
<body>
<h1>GeeksforGeeks</h1>

<p>A Computer Science portal for geeks</p>

</body>
</html>
XML: XML (eXtensible Markup Language) is also used to create web pages
and web applications. It is dynamic because it is used to transport the data not
for displaying the data. The design goals of XML focus on simplicity, generality,
and usability across the Internet. It is a textual data format with strong support
via Unicode for different human languages. Although the design of XML focuses
on documents, the language is widely used for the representation of arbitrary
data structures such as those used in web services.
Example:
html
<?xml version = "1.0"?>
<contactinfo>
<address category = "college">
<name>G4G</name>
<College>Geeksforgeeks</College>
<mobile>2345456767</mobile>
</address>
</contactinfo>

HTML XML

1. It was written in 1993. It was released in 1996.

HTML stands for Hyper Text XML stands for Extensible Markup
2.
Markup Language. Language.

3. HTML is static in nature. XML is dynamic in nature.

It was developed by It was developed by Worldwide Web


4.
WHATWG. Consortium.

It is termed as a presentation It is neither termed as a presentation nor


5.
language. a programming language.

XML provides a framework to define


6. HTML is a markup language.
markup languages.

7. HTML can ignore small errors. XML does not allow errors.

It has an extension of .html


8. It has an extension of .xml
and .htm

9. HTML is not Case sensitive. XML is Case sensitive.

HTML tags are predefined


10. XML tags are user-defined tags.
tags.

11. How do you list the databases tables in PHP?


To list the tables in a MySQL database using PHP, you can utilize the MySQLi (MySQL
Improved) extension, which is commonly used for working with MySQL databases in
PHP. Here's a step-by-step guide to achieve this:

1. Establish a Database Connection: First, you need to connect to your MySQL database.
Make sure to replace the placeholders with your actual database credentials.
<?php
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$database = "your_database";

// Create a connection
$conn = new mysqli($servername, $username, $password, $database);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>

12. Write the connectivity string in PHP with Mysql database.

o connect to a MySQL database in PHP, you can use the mysqli extension. Here's a sample PHP

code with a connection string:


<?php
$servername = "localhost"; // Replace with your MySQL server hostname
$username = "your_username"; // Replace with your MySQL username
$password = "your_password"; // Replace with your MySQL password
$database = "your_database"; // Replace with the name of your MySQL database

// Create a connection
$connection = mysqli_connect($servername, $username, $password, $database);

// Check the connection


if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}

echo "Connected successfully";

// Close the connection when you're done


mysqli_close($connection);
?>

13. Write the methods of Math object of Java Script.

abs() It returns the absolute value of the given number.

acos() It returns the arccosine of the given number in radians.

asin() It returns the arcsine of the given number in radians.

atan() It returns the arc-tangent of the given number in radians.

cbrt() It returns the cube root of the given number.

ceil() It returns a smallest integer value, greater than or equal to the given number.

cos() It returns the cosine of the given number.

cosh() It returns the hyperbolic cosine of the given number.

exp() It returns the exponential form of the given number.

floor() It returns largest integer value, lower than or equal to the given number.

hypot() It returns square root of sum of the squares of given numbers.


log() It returns natural logarithm of a number.

max() It returns maximum value of the given numbers.

min() It returns minimum value of the given numbers.

pow() It returns value of base to the power of exponent.

random() It returns random number between 0 (inclusive) and 1 (exclusive).

round() It returns closest integer value of the given number.

sign() It returns the sign of the given number

sin() It returns the sine of the given number.

sinh() It returns the hyperbolic sine of the given number.

sqrt() It returns the square root of the given number

tan() It returns the tangent of the given number.

tanh() It returns the hyperbolic tangent of the given number.

trunc() It returns an integer part of the given number.

14. What do you mean by internal Linking? How is it done in HTML?

What is a link?
It is a connection from one web resource to another. A link has two ends, An
anchor and direction. The link starts at the “source” anchor and points to the
“destination” anchor, which may be any Web resource such as an image, a
video clip, a sound bite, a program, an HTML document or an element within an
HTML document. You will find many websites or social media platforms ( Like
YouTube, and Instagram ) which link an image to a URL or a text to a URL etc.
This basically means that by using the ‘a’ tag, you can link 1 element of the
code to another element that may/may not be in your code.
HTML Link Syntax
Links are specified in HTML using the “a” tag.

<!DOCTYPE html>
<html>
<h3>Example Of Adding a link</h3>

<body>
<p>Click on the following link</p>
<a href="https://www.geeksforgeeks.org">GeeksforGeeks</a>
</body>

</html>
15.
1) Identifier in Java Script

JavaScript Identifiers are names given to variables, functions, etc. It is the same
as identifiers in other programming languages like C, C++, Java, etc. Let’s see
identifiers for variable names.

The following are legal variable names −

val
val1
result

While naming your variables in JavaScript, keep the following rules in mind.

 You should not use any of the JavaScript reserved keywords as a variable name. These
keywords are mentioned in the next section. For example, break or boolean variable names
are not valid.
 JavaScript variable names should not start with a numeral (0-9). They must begin with a
letter or an underscore character. For example, 5demo is an invalid variable name but
_5demo is a valid one.
 JavaScript variable names are case-sensitive. For example, Name and name are two different
variables.

15
2)Keywords in Java Script
In JavaScript, keywords are reserved words that have special meanings and purposes
within the language. These words cannot be used as identifiers (variable names, function
names, etc.) because they are already used by the JavaScript language itself. Here are
some common keywords in JavaScript:

1. var: Used to declare a variable.


2. let: Used to declare a block-scoped variable.
3. const: Used to declare a block-scoped constant variable.
4. if: Used to start a conditional statement.
5. else: Used in conjunction with an if statement to define an alternative block of code to
execute.
6. switch: Used to create a switch statement for multiple possible conditions.
7. case: Used within a switch statement to define different cases.
8. default: Used within a switch statement to specify a default case.
9. for: Used to create a for loop.
10. while: Used to create a while loop.
11. do: Used to create a do-while loop.
12. break: Used to exit a loop or switch statement.
13. continue: Used to skip the current iteration of a loop.
14. function: Used to declare a function.
15. return: Used to exit a function and specify its return value.
16. class: Used to define a class in ECMAScript 6 (ES6) and later.
17. new: Used to create a new object instance.
18. this: Refers to the current object within a method.
19. try: Used to create a try-catch block for error handling.
20. catch: Used in conjunction with try to catch and handle exceptions.
21. throw: Used to throw an exception.
22. finally: Used in conjunction with try to specify a block of code that is always
executed.
23. delete: Used to delete an object property.
24. typeof: Used to check the data type of a value.
25. instanceof: Used to check if an object is an instance of a particular class or constructor.

16. Write a PHP script which takes the user name, password and email values from user
and checks whether the user has filled the textboxes or not. Also, check the email field
whether it is incorrect format or not.
create a simple PHP script to take user input for a username, password, and email, and
then check whether the fields are filled and if the email is in the correct format. Here's a
basic example:
<!DOCTYPE html>
<html>
<head>
<title>Form Validation</title>
</head>
<body>

<?php
// Define variables to store user input and error messages
$username = $password = $email = "";
$usernameErr = $passwordErr = $emailErr = "";

// Function to validate the input


function validateInput($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Check if the username is filled
if (empty($_POST["username"])) {
$usernameErr = "Username is required";
} else {
$username = validateInput($_POST["username"]);
}
// Check if the password is filled
if (empty($_POST["password"])) {
$passwordErr = "Password is required";
} else {
$password = validateInput($_POST["password"]);
}

// Check if the email is filled and in the correct format


if (empty($_POST["email"])) {
$emailErr = "Email is required";
} else {
$email = validateInput($_POST["email"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$emailErr = "Invalid email format";
}
}
}
?>

<h2>Form Validation</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Username: <input type="text" name="username">
<span class="error"><?php echo $usernameErr; ?></span>
<br><br>

Password: <input type="password" name="password">


<span class="error"><?php echo $passwordErr; ?></span>
<br><br>

Email: <input type="text" name="email">


<span class="error"><?php echo $emailErr; ?></span>
<br><br>

<input type="submit" name="submit" value="Submit">


</form>

<?php
// If all fields are filled and email is in the correct format, you can process the data here
if (!empty($username) && !empty($password) && !empty($email) && empty($usernameErr)
&& empty($passwordErr) && empty($emailErr)) {
// Process the data, e.g., store it in a database or perform some action
echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>";
echo "Email: " . $email . "<br>";
}
?>

</body>
</html>

17. Discuss Java script array object in details.

The Array object lets you store multiple values in a single variable.
It stores a fixed-size sequential collection of elements of the same
type. An array is used to store a collection of data, but it is often
more useful to think of an array as a collection of variables of the
same type.

Syntax

Use the following syntax to create an Array object −


var fruits = new Array( "apple", "orange", "mango" );

Array Properties
Here is a list of the properties of the Array object along with their
description.

Sr.No. Property & Description

constructor
1
Returns a reference to the array function that created the object.

index
2
The property represents the zero-based index of the match in the string

input
3
This property is only present in arrays created by regular expression matches.

length
4
Reflects the number of elements in an array.

prototype
5
The prototype property allows you to add properties and methods to an objec

Array Methods
Here is a list of the methods of the Array object along with their
description.

Sr.No. Method & Description

concat()
1
Returns a new array comprised of this array joined with other array(s) and/or value(s).

every()
2
Returns true if every element in this array satisfies the provided testing function.

filter()
3 Creates a new array with all of the elements of this array for which the provided filtering
function returns true.
forEach()
4
Calls a function for each element in the array.

indexOf()
5 Returns the first (least) index of an element within the array equal to the specified value,
or -1 if none is found.

18. Write a Java Script which displays current date and time.

This tutorial teaches us to get the date and time in JavaScript. Nowadays,
JavaScript is the most popular programming language used for user interaction
with the browser. We can say that it is hard to find a single web application that
does not use JavaScript.

The purpose of creating this tutorial is to make programmers familiar with


the Date() object. Users can get today’s date and current time using the date
class. While developing the applications, programmers maybe need to show the
current date and time according to the user’s local zone, and we can fill this
requirement using the date class. Also, sometimes we need to store the user’s
session start and end times in our app database.

To solve all the problems, we just create an object of date class and use its various
methods to get the current date and time in this tutorial.

 Get Date and Time using the Date Object


 Get date and time using the toLocaleString() Method

Get Date and Time using the Date Object


The Date class contains several methods; we can fetch the current date, day,
and time by using them. Also, it includes hundreds of different methods that
programmers can use according to their requirements.

Syntax
<!DOCTYPE html>
<html>
<head>
<title>Display Current Date and Time</title>
</head>
<body>
<div id="datetime"></div>

<script>
// Function to update the date and time
function updateDateTime() {
var now = new Date();
var datetimeElement = document.getElementById("datetime");
datetimeElement.innerHTML = "Current Date and Time: " +
now.toLocaleString();
}

// Call the function initially


updateDateTime();

// Update the date and time every second (1000 milliseconds)


setInterval(updateDateTime, 1000);
</script>
</body>
</html>

You might also like