Final PW Lab PGM Vtu1
Final PW Lab PGM Vtu1
BY MANJU:--
1. Develop and demonstrate a XHTML document that illustrates the use external style
sheet, ordered list, table, borders, padding, color, and the <span> tag.
lab1.html
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head><title>Ordered List</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<body bgcolor="orange">
<h1>Ordered List</h1>
<ol><li>Software Engineering</li>
<ol>
<li>Six essentials of SE</li>
<li>Emergent Properties of SE</li>
<li>Socio technical reasons of SE</li>
<ol>
<li>Security</li>
<li>Vulnerability</li>
</ol>
</ol>
</ol>
<h1>Table</h1>
<table border=1 >
<tr class="row1">
<th>Emp Number</th>
<th>Name</th>
<th>Designation</th>
<th>Date of Joining</th>
<th>Salary</th>
</tr>
<tr class="row2">
<td>E101</td>
<td>Rakesh</td>
<td>Software Engineer</td>
<td>24-4-1998</td>
<td>22000</td>
</tr>
<tr class="row2">
<td>E102</td>
<td>Rajesh</td>
<td>Senior Engineer</td>
1 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
<td>24-4-1999</td>
<td>18000</td>
</tr>
<tr class="row2">
<td>E103</td>
<td>Prashanth</td>
<td>Software Engineer</td>
<td>24-4-2000</td>
<td>18000</td>
</tr>
</table>
<h1>Representing Border Style</h1>
<p class="borders1">Welcome to CGI programming</p>
<p class="borders3">Welcome to Scripting</p>
<p class="borders2">Welcome to CSS</p>
<h1>Representing Span tag</h1>
<p><span class="spanblue">dsfk</span>Welcome to HTML with CSS</p>
<p class="borders2">klsjdfklsj<span class="spanblue">dsfk</span>Welcome to Scripting</p>
</body>
</html>
Style.css
h1{text-decoration:underline}
ol{list-style-type:upper-roman;}
ol ol{list-style-type:upper-alpha;}
ol ol ol{list-style-type:decimal;}
ol.one{list-style-type:lower-roman;}
ol.one ol.one {list-style-type:lower-alpha;}
ol.one ol.one ol.one{list-style-type:decimal;}
table { border-top-width:low;
border-bottom-width:thick;
border-left-width:medium;
border-right-width:thin;
border-top-color:red;
border-bottom-color:gray;
border-left-color:blue;
border-right-color:purple;
border-top-style:dotted;
border-bottom-style:dashed;
border-left-style:double;
border-right-style:line;
2 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
margin-left:0.5in;
margin-right:0.5in;
margin-top:0.5in;
margin-bottom:0.4in;
padding-left:7in;
padding-right:9in;
padding-top:12.5in;
padding-bottom:1.4in;
}
tr.row1{background:"red";}
tr.row2{color:"teal";}
p.borders1{border-style:dashed;}
p.borders2{border-style:dotted;}
p.borders3{border-style:double;}
.spanblue{font-size:24pt;
font-family:"gothic";
color:"blue";
font-weight:300;
}
OUTPUT:
3 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
2. Develop and demonstrate a XHTML file that includes Javascript script for the following
problems:
a) Input: A number n obtained using prompt
Output: The first n Fibonacci numbers
<?xml version = "1.0" encoding = "utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<script type="text/javascript">
var fib1=0,fib2=1,fib=0;
var num = prompt("Enter a number : \n", "");
for(i=3;i<=num; i++)
{
fib= fib1 + fib2;
document.write("<h1> " + fib + "</h1>");
fib1=fib2;
fib2=fib;
}
}
else
alert("No Proper Input");
</script>
</body>
</html>
Output:--
4 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
<!-- lab2b.html
A trivial document
-->
Output:--
5 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
3. Develop and demonstrate a XHTML file that includes Javascript script that uses
functions for the following problems:
a) Parameter: A string
Output: The position in the string of the left-most vowel
var ia = text.toLowerCase().indexOf("a");
var ie = text.toLowerCase().indexOf("e");
var ii = text.toLowerCase().indexOf("i");
var io = text.toLowerCase().indexOf("o");
var iu = text.toLowerCase().indexOf("u");
6 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
3. b) Parameter: A number
Output: The number with its digits in the reverse order
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
function disp(num)
{
var rn=0, n= Number(num.value);
while(n!=0)
{
r = n%10;
n = Math.floor(n/10);
rn = rn*10 + r;
}
alert("The " + num.value + " in reverse is " + rn);
}
</script>
</head>
<body>
Enter a number :
<input type=text name=number>
<input type="button" value="Click me!" onclick="disp(number)" >
</body>
</html>
Output:--
7 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
</form>
</body>
</html>
8 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
4b) Modify the above program to get the current semester also
(restricted to be a number from 1 to 8)
4b.html
<html>
<head>
<script language = "javascript">
function getsem()
{
var usn = document.f1.t1.value;
reg= /^([1-4][A-Z][A-Z]\d{2}[A-Z][A-Z]\d{3})$/ ;
var k= reg.test(usn) ;
if(k==false)
{
alert("Invalid USN = "+ usn +" test = " + reg.test(usn));
}
if (k==true)
{
alert("valid USN = "+ usn +" test = " + reg.test(usn));
var s = usn.substring(3,5);
var s1 = parseInt(s);
var today=new Date();
var thisyear = today.getFullYear();
var k=s;
var k1="20"+s;
var joinyear = parseInt(k1);
var y=thisyear-joinyear;
if(y>3)
{
y=3;
}
var m=today.getUTCMonth();
m=m+1;
if(m<7)
{
sem=(y*2);
}
else
{
sem=(y*2)+1
}
alert("Semester = " +sem);
}
}
</script>
</head>
<body>
<form name = "f1">
<input type = "text" name = "t1" value = "">
<input type = "button" value = "Click Me" onclick ="getsem()">
</form>
</body>
</html>
9 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
5a.html
<CTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Program 5</title>
<link rel="stylesheet" href="./style.css" media="screen" type="text/css" />
<script type="text/javascript">
var topLayer="layer3";
function mover(toTop)
{
oldTop.zIndex="0";
newTop.zIndex="10"
topLayer=document.getElementById(toTop).id;
}
</script>
</head>
<body>
<h1>
<div id="layer1" style="background: #f000f0; z-index: 10;position: absolute; left: 10px; top:
100px; width: 400px;" onmouseover="mover('layer1')">
a0) Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi dapibus.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
</div>
<div id="layer2" style="background: #00f0f0; z-index: 2; position: absolute; left: 60px; top:
150px; width: 400px;" onmouseover="mover('layer2')">
a1) Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi dapibus.
Donec vitae pede a nisl ultricies viverra. Integer bibendum.
10 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
Fusce ipsum quam, accumsan a, ornare at, consectetuer sit amet, diam.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
</div>
<div id="layer3" style="background: #f0f000; z-index: 0; position: absolute; left: 110px; top:
200px; width: 400px;" onmouseover="mover('layer3')">
a2) Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi dapibus.
Donec vitae pede a nisl ultricies viverra. Integer bibendum.
Fusce ipsum quam, accumsan a, ornare at, consectetuer sit amet, diam.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
</div>
</body>
</html>
Style.css
body {
font-family: 'Arial', sans-serif;
font-size: 14px;
}
h1 {
font-size: 18px;
font-style: italic;
}
a{
color: #7070f0;
text-decoration: none;
}
a:visited {
color: #7070f0;
text-decoration: none;
}
a:hover {
color: #9090f9;
text-decoration: underline;
}
11 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
5b) Modify the above document so that when a paragraph is moved from
the top stacking position, it returns to its original position rather than to
the bottom
5b.html
<h1>
b) Paragraphs that come to top on mouse hover and move back to original position on mouse
out
</h1>
<div id="b0" style="background: #f000f0; z-index: 0; position: absolute; left: 10px; top:
500px; width: 400px;" onmouseover="bringToTop('b',0,3);" onmouseout="resetPosition('b',0);">
b0) Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi dapibus.
Donec vitae pede a nisl ultricies viverra. Integer bibendum.
Fusce ipsum quam, accumsan a, ornare at, consectetuer sit amet, diam.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
gravida vitae, cursus et, sem.
12 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
</div>
<div id="b1" style="background: #00f0f0; z-index: 1; position: absolute; left: 60px; top:
550px; width: 400px;" onmouseover="bringToTop('b',1,3);" onmouseout="resetPosition('b',1);">
b1) Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi dapibus.
Donec vitae pede a nisl ultricies viverra. Integer bibendum.
Fusce ipsum quam, accumsan a, ornare at, consectetuer sit amet, diam.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
aliquam, pede ut aliquam iaculis,
lectus quam cursus mauris, nec rhoncus metus eros vitae nibh.
</div>
<div id="b2" style="background: #f0f000; z-index: 2; position: absolute; left: 110px; top:
600px; width: 400px;" onmouseover="bringToTop('b',2,3);" onmouseout="resetPosition('b',2);">
b2) Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi dapibus.
Donec vitae pede a nisl ultricies viverra. Integer bibendum.
Fusce ipsum quam, accumsan a, ornare at, consectetuer sit amet, diam.
Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
</div>
</body>
</html>
Style.css
body {
font-family: 'Arial', sans-serif;
font-size: 14px;
}
h1 {
font-size: 18px;
font-style: italic;
}
a{
color: #7070f0;
text-decoration: none;
}
a:visited {
color: #7070f0;
text-decoration: none;
}
a:hover {
color: #9090f9;
text-decoration: underline;
}
13 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
14 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
<students>
<usn><regno> Register Number :</regno> 1SSO6CS004 </usn>
<name><name1> NAME :</name1> CJCJCJCJCJ </name>
<college><cname> College :</cname> SSIT </college>
<branch><course> COURSE :</course> CS </branch>
<joiningyear><jy> Year of Joining :</jy> 2005 </joiningyear>
<emailid><email> Email :</email> [email protected]</emailid>
</students>
</student>
lab6a.css
student
{
background-color: cyan;
width: 100%;
}
title{
font-weight:bold;
font-color:maroon;
font-size:65pt;
text-decoration:underline;
margin-left:250pt;
}
students
{
display: block;
margin-bottom: 30pt;
margin-left: 10pt;
background-color:pink;
}
usn,name,college,branch,joiningyear,emailid
{
font-size:20pt;
display: block;
color: #000000;
margin-left: 20pt;
}
regno,name1,cname,course,jy,email{
font-size:30pt;
font-weight:bold;
font-color:blue;
}
15 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
6b) Create an XSLT style sheet for one student element of the above
document and use it to create a display of that element.
6b.xml
<?xml version = "1.0"?>
<!-- 6b.xml -->
<?xml:stylesheet type = "text/xsl" href = "6b.xsl" ?>
<VTU>
<USN> 1RN08ISE </USN>
<name> Amar </name>
<college> RNSIT </college>
<branch> ISE </branch>
<YOJ> 2007 </YOJ>
<email> [email protected] </email>
</VTU>
6b.xsl
<?xml version = "1.0"?>
<!-- 6b.xsl An XSLT Stylesheet for 5b.xml using templates -->
<xsl:stylesheet version = "1.0"
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns = "http://www.w3.org/1999/xhtml">
16 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
Program7a.html
<html>
<head><title>Server Info</title></head>
<body bgcolor=orange><br>
<form action="http://localhost/cgi-bin/program7a.pl" method="get">
<center><input type="submit" value="Show Server Information"></center>
</form>
</body>
</html>
program7a.pl
#!/usr/bin/perl
print<<1a;
Content-type:text/html\n\n
<html>
<head><title>Environment Variables</title></head>
<body bgcolor=orange>
<table cellpadding=5 border=1>
<tr>
<th>ENV-VARIABLE</th>
<th>VALUE</th>
</tr>
1a
foreach $i(sort keys %ENV) {
print "<tr><td>$i<td>$ENV{$i}</tr>";
}
print "</table></body></html>";
17 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
7b) Write a Perl program to accept UNIX command from a HTML form
and to display the output of the command executed.
Program7b.html
<html>
<head><title>Unix Command</title></head>
<body bgcolor=orange>
<form method=GET action="http://localhost/cgi-bin/program7b.pl" name=form1>
<center><br><H1>ENTER UNIX COMMAND TO BE EXECUTED</H1>
<input type=text name=msg><p>
<input type=submit value="CLICKME">
</form>
</body>
</html>
program7b.pl
#!/usr/bin/perl
use CGI;
$q=new CGI;
$cmd=$q->param("msg");
print<<1b;
Content-type:text/html\n\n
<html>
<head><title>Unix Command</title></head>
<body bgcolor=orange>
<h1><pre><center>
The output of UNIX command is <br>
1b
system($cmd);
print "</center></h1></body></html>";
--------------------------------------------------------------------------------------------------------------------
18 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
8a.html
<html>
<head><title> name </title></head>
<body bgcolor="aabbcc">
<h3> enter name & receive the greetings </h3>
<form action="/cgi-bin/8a.pl" method="get">
name:<input type="text" name="name"><br/><br/>
<input type="submit" value="submit">
<input type="reset" value="reset">
</form>
</body>
</html>
8a.pl
#!/usr/bin/perl
use strict;
use CGI':standard';
my $name=param("name");
print header();
print start_html(-title=>'Greeting message'-bgcolor=>'1E90FF');
print h2("Hello $name");
my $r=int(rand(4));
print "random-".$r;
if($r==0) {
print h2("Hai".$name);
}
if($r==1) {
print h2("great Day".$name);
}
print "<br>";
if($r==2) {
print h2("Welcome".$name);
}
print "<br>";
if($r==3) {
print h2("Good day".$name);
}
print end_html();
19 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
8. b) Write a Perl program to keep track of the number of visitors visiting the web page
and to display this count of visitors, with proper headings.
8b.pl
#! /usr/bin/perl
use CGI’:standard’;
use strict;
use DBI;
my $c;
my $dbh=DBI->connect(‘DBI:mysql’,’root’,’iamgod’);
my $sth=$dbh->prepare(‘select * from visitors’);
$sth->execute();
$c=$sth->fetchrow();
print header(),
start_html(),
h1(“count=$c”),
end_html();
$c=$c+1;
$sth=$dbh->prepare(‘update visitors set count=?’);
$sth->execute($c);
$sth->finish();
$dbh->disconnect();
exit(0);
//check single quotes and double quotes correctly in above pgm//pgm is fine!!
11.php
<?php
$value=`date +%D%T`;
$xyz= 60 * 60 *24 *60 + time();
setcookie("TestCookie",$value, $xyz);
echo "Cookie has been set";
echo "The Last visited Time and Date";
echo $_COOKIE["TestCookie"];
?>
20 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
12.php
<?php
session_start();
session_register("count");
if (!isset($_SESSION))
{
$_SESSION["count"] = 0;
echo "<p>Counter initialized</p>\n";
}
else { $_SESSION["count"]++; }
10. Write a Perl program to insert name and age information entered by the
user into a table created using MySQL and to display the current contents of
this table.
<html>
<body>
<form action="http://localhost/cgi-bin/10.pl">
Name : <input type="text" name="name"> <br>
Age :<input type="text" name="age"> <br>
<input type="submit" value="Submit">
</form>
</body>
</html>
10.pl
#! /usr/bin/perl
print "Content-type: text/html\n\n";
print "<HTML><TITLE>Result of the insert operation </TITLE>";
use CGI ':standard';
use DBI;
$dbh=DBI->connect("DBI:mysql:test","root","");
$name=param("name");
$age=param("age");
21 http://firefriendsmanju.webs.com| :-
Pw lab pgms:
while ( ($name,$age)=$qh->fetchrow())
{
print "<tr><td>$name</td><td>$age</td></tr>";
}
print "</table>";
$qh->finish();
$dbh->disconnect();
print"</HTML>";
22 http://firefriendsmanju.webs.com| :-