WT Practical
WT Practical
WT Practical
181243107004
PRACTICAL: 1
What is HTML?
HTML is the standard markup language for creating Web pages.
HTML stands for Hyper Text Markup Language.
HTML describes the structure of Web pages using markup.
HTML elements are the building blocks of HTML pages.
HTML elements are represented by tags.
HTML tags label pieces of content such as "heading", "paragraph", "table", and so on.
Browsers do not display the HTML tags, but use them to render the content of the page.
INPUT:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
OUTPUT:
My First Heading
My first paragraph.
EXAMPLE EXPLAINED:
The <!DOCTYPE html> declaration defines this document to be HTML5.
The <html> element is the root element of an HTML page.
The <head> element contains meta information about the document.
The <title> element specifies a title for the document.
The <body> element contains the visible page content.
The <h1> element defines a large heading.
The <p> element defines a paragraph.
XHTML
What is XHTML?
XHTML stands for Extensible Hypertext Markup Language.
XHTML is almost identical to HTML.
XHTML is stricter than HTML.
XHTML is HTML defined as an XML application.
XHTML is supported by all major browsers.
Why XHTML?
Many pages on the internet contain "bad" HTML.
This HTML code works fine in most browsers (even if it does not follow the HTML rules)
<html>
<head>
<title>This is bad HTML</title>
<body>
<h1>Bad HTML
<p>This is a paragraph
</body>
Today's market consists of different browser technologies. Some browsers run on computers, and some
browsers run on mobile phones or other small devices. Smaller devices often lack the resources or power to
interpret "bad" markup.
XML is a markup language where documents must be marked up correctly (be "well-formed").
If you want to study XML, please read our XML tutorial.
Web Technology (2160708) Page 2
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL.
181243107004
XHTML Elements
XHTML elements must be properly nested
XHTML elements must always be closed
XHTML elements must be in lowercase
XHTML documents must have one root element
XHTML Attributes
Attribute names must be in lower case
Attribute values must be quoted
Attribute minimization is forbidden
PRACTICAL: 2
AIM: Basic Tags in HTML.
<meta name="description" content="The adventures of my favourite pet cat Lucky, with stories, pictures and
movies.">
</head>
Web Technology (2160708) Page 4
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL.
181243107004
<h1>Sidebar Heading</h1>
<p>Sidebar text</p>
</div>
PRACTICA: 3
AIM:(A)Write a program to create lists.
<html>
<body>
<p><b><u> Ordered List</b></u></p>
<ol>
<li>a</li>
<li>s</li>
</ol>
<p><b><u> Unordered List</b></u></p>
<ul>
<li>a</li>
<li>s</li>
</ul>
<p><b><u> Nested List</b></u></p>
<OL TYPE = A START =3>
<LI> Bike
<OL TYPE = I>
<LI> FZ
<LI> Honda
<LI> R15
</OL>
<LI> Cars
<OL TYPE = I>
<LI> i10
<LI> i20
<LI> swift
</OL>
</OL>
<p><b><u> Definition List </b></u></p>
<dl>
<dt> Drinks </dt>
OUTPUT:
<html>
<head><META http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<div>
<table border="5" bgcolor="gray">
<caption>A Test table with merged cells</caption>
<tr>
<td rowspan="2">
</td>
<td colspan="2"><b><center>Average</center></b></td>
<td rowspan="2"><b>Red Eyes</b></td>
</tr>
<tr>
<td><b>Height</b></td>
<td><b>Weight</b></td>
</tr>
<tr>
<td><b>Males</b></td>
<td>1.9</td>
<td>0.003</td>
<td>40%</td>
</tr>
<tr>
<td><b>Females
</b></td>
<td>1.7</td>
<td>0.002</td>
<td>43%</td>
</tr>
</table>
</div>
</body>
</html>
OUTPUT:
PRACTICAL: 4
AIM: Introduction to CSS.
What is CSS?
CSS stands for Cascading Style Sheets.
CSS describes how HTML elements are to be displayed on screen, paper, or in other media.
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
External stylesheets are stored in CSS files.
Each declaration includes a CSS property name and a value, separated by a colon.
A CSS declaration always ends with a semicolon, and declaration blocks are surrounded by curly braces.
In the following example all <p> elements will be center-aligned, with a red text color:
EXAMPLE:
<html>
<head>
<style>
p
{
color: red;
text-align: center;
}
</style>
</head>
<body>
<p>Hello World!</p>
<p>These paragraphs are styled with CSS.</p>
</body>
</html>
OUTPUT:
Hello World!
These paragraphs are styled with CSS.
PRACTICAL: 5
AIM: Write a program to create menu using HTML and CSS.
<html>
<head>
<title>menu</title>
<link rel="stylesheet" type="text/css" href="E:\SPEC\Even term 16-17\Web Tech\Practical
solution\style.css" />
<head>
<style type="text/css">
body
{
font-family: Arial, Helvetica, sans-serif, Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: center;
background: #E3CAA1;
}
ul
{
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
ul li
{
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
cursor: pointer;
}
ul li:hover
{
background: #555;
color: #fff;
}
ul li ul
{
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
opacity: 0;
visibility: hidden;
}
ul li ul li
{
background: #CCCC33;
display: block;
color: #FF0000;
text-shadow: 0 -1px 0 #000;
}
ul li ulli:hover
{
background: #9966CC;
}
ulli:hoverul
{
display: block;
opacity: 1;
visibility: visible;
}
</style>-
</head>
<body>
<ul><li>Home</li>
<li>About</li>
<li>
Portfolio
<ul>
<li>Designing</li>
<li>Development</li>
</ul>
</li>
<li>Blog
<ul>
<li>Development</li>
<li>Illustrations</li>
</ul></li>
<li>Contact</li>
<li>Facilities</li>
<li>Downloads</li>
</ul>
</li>
</ul>
</body>
</html>
OUTPUT:
PRACTICAL: 6
AIM: Design a simple form to register for new user including user_name,
password, email, mobile number, gender, hobbies and address.
<html>
<head>
<title>Form</title>
<style type="text/css">
table,td {border: 0px solid black; border-collapse: collapse;padding: 5px;}
td {padding: 5px;}
input.in,textarea,select
{
padding: 5px;
border-width: 2px;
border-color: #00ccff;
border-radius: 2px;
border-style: solid;
}
</style>
</head>
<body>
<h1 align="center">register form</h1>
<form>
<table align="center">
<tr>
<td>User_name</td>
</td>
</tr>
<tr>
<td>Gender:</td>
<td>
<select name="dropdown" >
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
</select>
</td>
</tr>
<tr>
<td>Hobbies:</td>
<td>
<input name="music" class="in" type="checkbox" name="music" checked>Music</input
class="in">
<input name="sports" class="in" type="checkbox" name="Sports">Sports</input
class="in">
<input name="games" class="in" type="checkbox" name="Games">Games</input
class="in">
<input name="others" class="in" type="checkbox" name="other">other</input class="in">
</td>
</tr>
<tr>
<td>Address:</td>
<td><textarea name="addr" rows="5" cols="45" required></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit"></button></td>
</tr>
</table>
</form>
</body>
</html>
OUTPUT:
PRACTICAL: 7
Web Technology (2160708) Page 21
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL.
181243107004
An Introduction to JavaScript
Let’s see what’s so special about JavaScript, what we can achieve with it and which other technologies play
well with it.
What is JavaScript?
Java Script was initially created to “make Webpages alive”.
The programs in this language are called scripts. They can be written right in the HTML and execute
automatically as the page loads.
Scripts are provided and executed as a plain text. They don’t need a special preparation or a compilation to run.
In this aspect, JavaScript is very different from another language called Java.
Why JavaScript?
When JavaScript was created, it initially had another name: “Live Script”. But Java language was very popular
at that time, so it was decided that positioning a new language as a “younger brother” of Java would help.
But as it evolved, JavaScript became a fully independent language, with its own specification called ECMA
Script, and now it has no relation to Java at all.
At present, JavaScript can execute not only in the browser, but also on the server, or actually on any device
where there exists a special program called the JavaScript engine.
The browser has an embedded engine, sometimes it’s also called a “JavaScript virtual machine”.
Different engines have different “codenames”, for example:
V8 – in Chrome and Opera.
Spider Monkey – in Firefox.
There are other codenames like “Trident”, “Chakra” for different versions of IE, “Chakra Core” for
Microsoft Edge, “Nitro” and “Squirrelfish” for Safari etc.
The terms above are good to remember, because they are used in developer articles on the internet. We’ll use
them too. For instance, if “a feature X is supported by V8”, then it probably works in Chrome and Opera.
How engines work?
Engines are complicated. But the basics are easy.
The engine (embedded if it’s a browser) reads (“parses”) the script.
Then it converts (“compiles”) the script to the machine language.
And then the machine code runs, pretty fast.
The engine applies optimizations on every stage of the process. It even watches the compiled script as it
runs, analyzes the data that flows through it and applies optimizations to the machine code based on that
knowledge. At the end, scripts are quite fast.
JavaScript can easily communicate over the net to the server where the current page came from. But its ability
to receive data from other sites/domains is crippled. Though possible, it requires explicit agreement (expressed
in HTTP headers) from the remote side. Once again, that’s safety limitations.
Such limits do not exist if JavaScript is used outside of the browser, for example on a server. Modern browsers
also allow installing plug-in/extensions which may get extended permissions.
PRACTICAL: 8
AIM: Write a program to print date using JavaScript.
<html>
<body>
<h1>My First JavaScript</h1>
<p>Click the button to display the date.</p>
<p id="demo"></p>
<button type="button" onclick="myFunction()">print date</button>
<script>
functionmyFunction()
{
document.getElementById("demo").innerHTML = Date();
}
</script>
</body>
</html>
OUTPUT:
PRACTICAL: 9
AIM: Write a program to Sum
and Multiply two numbers using
JavaScript.
<html>
<head>
<title>Practical 13</title>
</head>
<body>
<script type="text/javascript">
document.write("The Addition of 5 and 7 is "+(5+7));
document.write("<br>The multiplication of 5 and 7 is "+(5*7));
</script>
</body>
</html>
OUTPUT:
PRACTICAL: 10
AIM: Write a program to Show use of alert, confirm and prompt box.
<html>
<head>
<title>java script</title>
<script type="text/javascript">
function confirmation()
{
var answer = confirm("Welcome spectera 7E2")
if (answer)
{
alert("Welcome!")
window.location = "http://spectera.accit.in";
}else{
alert("Bye bye!!")
}
}
function prompter()
{
var reply = prompt("What's your name?", "")
alert ( "Nice to see you " + reply + "!")
}
</script>
</head>
<body>
<h1 align="center"> Java Script Alert, Confirm and Prompt Box. </h1>
<form style="height:200px; width:200px; background-color:#CC3366;">
Web Technology (2160708) Page 27
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL.
181243107004
PRACTICAL: 11
Web Technology (2160708) Page 29
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL.
181243107004
document.write(b + "<br>");
document.write(c + "<br>");
document.write(d + "<br>");
</script>
</br>
</body>
</html>
OUTPUT:
PRACTICAL: 12
break;
default:
document.write("<b> You have entered Wrong operator </b>");
document.write("<br \> Please enter Correct operator such as +, -, *, /, %");
}
</script>
</body>
</html>
OUTPUT:
PRACTICAL: 13
AIM: Create validation Form in JavaScript.
<html>
<head>
<script type='text/javascript'>
function formValidator()
{
var firstname = document.getElementById('firstname');
var addr = document.getElementById('addr');
var zip = document.getElementById('zip');
var state = document.getElementById('state');
var username = document.getElementById('username');
var email = document.getElementById('email');
if(isAlphabet(firstname, "Please enter only letters for your name"))
{
if(isAlphanumeric(addr, "Numbers and Letters Only for Address"))
{
if(isNumeric(zip, "Please enter a valid zip code"))
{
if(madeSelection(state, "Please Choose a State"))
{
if(lengthRestriction(username, 6, 8))
{
if(emailValidator(email, "Please enter a valid email address"))
{
return true;
}
}
}
}
}
}
return false;
}
function notEmpty(bhatt, helperMsg)
{
if(bhatt.value.length == 0)
{
alert(helperMsg);
bhatt.focus();
return false;
}
return true;
}
function isNumeric(bhatt, helperMsg)
{
var numericExpression = /^[0-9]+$/;
if(bhatt.value.match(numericExpression))
{
return true;
}
else
{
alert(helperMsg);
bhatt.focus();
return false;
}
}
function isAlphabet(bhatt, helperMsg)
{
var alphaExp = /^[a-zA-Z]+$/;
if(bhatt.value.match(alphaExp)){
return true;
}
Else
{
alert(helperMsg);
hatt.focus();
return false; }
}
function isAlphanumeric(bhatt, helperMsg)
{
var alphaExp = /^[0-9a-zA-Z]+$/;
if(bhatt.value.match(alphaExp))
{
return true;
}
else
{
alert(helperMsg);
bhatt.focus();
return false;
}
}
function lengthRestriction(bhatt, min, max)
{
var uInput = bhatt.value;
if(uInput.length >= min && uInput.length <= max)
{
return true;
}else{
alert("Please enter between " +min+ " and " +max+ " characters");
bhatt.focus();
return false;
} \
}
function madeSelection(bhatt, helperMsg)
{
if(bhatt.value == "Please Choose"){
alert(helperMsg);
bhatt.focus();
return false;
}else{
return true;
}
}
OUTPUT:
PRACTICAL: 14
PHP – INTRODUCTION
PHP started out as a small open source project that evolved as more and more people found out how useful it
was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
PHP can handle forms, i.e. gather data from files, save data to a file, through email you can send data,
return data to the user.
You add, delete, modify elements within your database through PHP.
Access cookies variables and set cookies.
Using PHP, you can restrict users to access some pages of your website.
It can encrypt data.
Characteristics of PHP:
Simplicity
Efficiency
Security
Flexibility
Familiarity
To get a feel for PHP, first start with simple PHP scripts. Since "Hello, World!" is an essential example, first
we will create a friendly little "Hello, World!" script.
As mentioned earlier, PHP is embedded in HTML. That means that in amongst your normal HTML (or
XHTML if you're cutting-edge) you'll have PHP statements like this −
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?php echo "Hello, World!";?>
</body>
</html>
Hello, World!
If you examine the HTML output of the above example, you'll notice that the PHP code is not present in the
file sent from the server to your Web browser. All of the PHP present in the Web page is processed and
stripped from the page; the only thing returned to the client from the Web server is pure HTML output.
All PHP code must be included inside one of the three special markup tags ATE are recognized by the PHP
Parser.
A most common tag is the <?php...?> and we will also use the same tag in our tutorial.
From the next chapter we will start with PHP Environment Setup on your machine and then we will dig out
almost all concepts related to PHP to make you comfortable with the PHP language.
PRACTICAL: 15
OUTPUT:
PRACTICAL: 16
OUTPUT:
PRACTICAL: 17
</body>
</html>
OUTPUT:
PRACTICAL: 18
OUTPUT:
PRACTICAL: 19
<?php
$server = "localhost";
$userid = "root";
$password = "";
$db = "school";
$conn = mysqli_connect($server, $userid, $password, $db);
if ($conn)
{
echo "You connect with ".$db." database.";
}
else
{
echo mysqli_connect_error($conn);
}
if (isset($_POST['insert']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$class = $_POST['class'];
$query = "INSERT INTO student VALUES ('$fname', '$lname', '$gender', '$class')";
$result = mysqli_query($conn, $query);
if ($result) {
echo "<br> Your Data Inserted.";
}else{
echo mysqli_error($conn);
}
}
?>
<html>
<head>
<title>Insert Data</title>
</head>
<body>
<h1>Students Data</h1>
<form action="pre23.php" method="post">
Firstname:<br><br><input type="text" name="fname"><br><br>
Lastname:<br><br><input type="text" name="lname"><br><br>
Gender:
<input type="radio" name="gender" value="female">Female
<input type="radio" name="gender" value="male">Male
<input type="radio" name="gender" value="other">Other
<br><br>
Class:<input type="number" name="class"><br><br>
<input type="submit" name="insert" value="Insert">
</form>
</body>
</html>
OUTPUT:
DELETE DATA:
<?php
$server = "localhost";
$userid = "root";
$password = "";
$db = "school";
$conn = mysqli_connect($server, $userid, $password, $db);
if ($conn) {
echo "You connect with ".$db." database.";
}else{
echo mysqli_connect_error($conn);
}
Web Technology (2160708) Page 50
SARDAR PATEL COLLEGE OF ENGINEERING, BAKROL.
181243107004
if (isset($_POST['delete']))
{
$name = $_POST['name'];
$query = "DELETE FROM student WHERE firstname='$name'";
$result = mysqli_query($conn, $query);
if ($result)
{
echo "<br> Your Data Deleted.";
}else{
echo mysqli_error($conn);
}
}
?>
<html>
<head>
<title>Insert Data</title>
</head>
<body>
<h1>Students Data</h1>
<form action="pre24.php" method="post">
Name:<br><br><input type="text" name="name"><br><br>
<input type="submit" name="delete" value="Delete">
</form>
</body>
</html>
OUTPUT:
UPDATE DATA:
<?php
$server = "localhost";
$userid = "root";
$password = "";
$db = "school";
$conn = mysqli_connect($server, $userid, $password, $db);
if ($conn)
{
echo "You connect with ".$db." database.";
}
else
{
echo mysqli_connect_error($conn);
}
if (isset($_POST['update']))
{
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$gender = $_POST['gender'];
$class = $_POST['class'];
$query = "UPDATE student SET firstname='$fname', lastname='$lname', gender='$gender', class='$class'
WHERE firstname='$fname'";
$result = mysqli_query($conn, $query);
if ($result)
{
echo "<br> Your Data Updated.";
}
else
{
echo mysqli_error($conn);
}
}
?>
<html>
<head>
<title>Update Data</title>
</head>
<body>
<h1>Students Data</h1>
<?php
$query = "SELECT * FROM student WHERE firstname='Jai'";
$res = mysqli_query($conn,$query);
while ($row = mysqli_fetch_array($res,MYSQLI_BOTH)) {
$firstname = $row['firstname'];
$lastname = $row['lastname'];
$gender = $row['gender'];
$class = $row['class'];
?>
<form action="pre25.php" method="post">
Firstname:<br><br><input type="text" name="fname" value="<?php echo $firstname; ?
>"><br><br>
Lastname:<br><br><input type="text" name="lname" value="<?php echo $lastname; ?
>"><br><br>
Gender:<br><br><input type="text" name="gender" value="<?php echo $gender; ?>"><br><br>
Class:<br><br><input type="number" name="class" value="<?php echo $class; ?>"><br><br>
<input type="submit" name="update" value="Update">
</form>
<?php
}
?>
</body>
</html>
OUTPUT: