Sunteți pe pagina 1din 13

1a)

<?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">
<body>
<script type="text/Javascript">
var fib1=0,fib2=1,fib=0;
var num=prompt("Enter a number:\n","");
if(num!=null&&num>0)
{
document.write("<h1>"+num+"<br>Fibonacci are <br></h1>");
if(num==1)
document.write("<h1>"+fib1+"</h1>");
else
document.write("<h1>"+fib1+"<br>"+fib2+"</h1>");
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>
1b)
<?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">
<body>
<script type="text/Javascript">
var num=prompt("Enter a number:\n");
if(num>0&&num!=null)
{
msgst="Number and its square are\n";
for(i=1;i<=num;i++)
{
msgst=msgst+i+"-"+i*i+"\n";
}
alert(msgst);
}
else
alert("No proper Input");

</script>
</body>
</html>
2a)
<?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">
<script type="text/Javascript">
function formValidator()
{
var usn=document.getElementById('req1');
alert(usn.value);
if(isCorrect(usn))
{
return true;
}
return false;
}
function isCorrect(elem1)
{
alphaExp1=/[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/
if(elem1.value.length==0)
{
alert("US Number is empty");
elem1.focus();
return false;
}
else if(!elem1.value.match(alphaExp1))
{
alert("USN should be in DAADDAADDD format");
elem1.focus();
return false;
}
alert("USN is Correct");
return true;
}
</script>
<body>
<form onsubmit='return formValidator()'>
Enter your USN. in DAADDAADDD format:<input type='text' id='req1'/>
<input type='submit' value='Check Field'/>
</form>
</body>
</html>
2b)
<?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>
<script type="text/Javascript">
function formValidator()
{
var usn=document.getElementById('req1');
var sem=document.getElementById('req2');
if(isCorrect(usn))
{
if(isPerfect(sem))
return true;
}
return false;
}
function isPerfect(elem2)
{
var alphaExp2=/[1-8][1-8]$/
if(elem2.value.length==0)
{
alert("Semester Number is empty");
elem2.focus();
return false;
}
else if(!elem2.value.match(alphaExp2))
{
alert("Invalid Semester Number");
elem2.focus();
return false;
}
alert("Semester Number is Correct");
return true;
}
function isCorrect(elem1)
{
var alphaExp1=/[1-4][A-Z][A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9][0-9]$/
if(elem1.value.length==0)
{
alert("US Number is empty");
elem1.focus();
return false;
}
else if(!elem1.value.match(alphaExp1))
{
alert("USN should be in DAADDAADDD format");
elem1.focus();
return false;
}

alert("USN is Correct");
return true;
}
</script>
</head>
<body>
<form onsubmit='return formValidator()'>
Enter your USN. in DUUDDUUDDD format:<input type='text' id='req1'/><br/>
Enter your SEM. in D[1-8][1-8] format:<input type='text' id='req2'/><br/>
<input type='submit' value='Check Field'/>
</form>
</body>
</html>
3a)
<?xml version = "1.0" encoding="utf-8"?>
<!DOCTYPE html PUBIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/Javascript">
var top='125';
function toTop(newTop)
{
domTop=document.getElementById(top).style;
domNew=document.getElementById(newTop).style;
domTop.zIndex="0";
domNew.zIndex="10";
top=newTop;
}
</script>
<style type="text/css">
.para1{position:absolute;top:10;left:120;z-index:0;border:solid;padding:80;
width:300;background-color:blue;}
.para2{position:absolute;top:100;left:150;z-index:0;border:solid;padding:80;
width:300;background-color:green;}
.para3{position:absolute;top:150;left:180;z-index:0;border:solid;padding:80;
width:300;background-color:red;}
</style>
</head>
<body>
<p>
<p class="para1" id="123" onmouseover="toTop('123')">ACSCE
<p class="para3" id="125" onmouseover="toTop('125')">DEPARTMENT OF CSE
<p class="para2" id="124" onmouseover="toTop('124')">BANGALORE
</p>
</body>
</html>

3b)
<?xml version = "1.0" encoding="utf-8"?>
<!DOCTYPE html PUBIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/Javascript">
var top='125';
function toTop(newTop)
{
domTop=document.getElementById(top).style;
domNew=document.getElementById(newTop).style;
domTop.zIndex="0";
domNew.zIndex="10";
top=newTop;
}
</script>
<style type="text/css">
.para1{position:absolute;top:10;left:120;z-index:0;border:solid;padding:80;
width:300;background-color:blue;}
.para2{position:absolute;top:100;left:150;z-index:0;border:solid;padding:80;
width:300;background-color:green;}
.para3{position:absolute;top:150;left:180;z-index:0;border:solid;padding:80;
width:300;background-color:red;}
</style>
</head>
<body>
<p>
<p class="para1" id="123" onmouseover="toTop('123')" onmouseout="toTop('124')">ACSCE
<p class="para3" id="125" onmouseover="toTop('125')" onmouseout="toTop('124')">DEPARTMENT
OF CSE
<p class="para2" id="124" onmouseover="toTop('124')" onmouseout="toTop('124')">BANGALORE
</p>
</body>
</html>
4a.xml)
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/css" href="4a.css"?>
<students>
<p>vtu students description</p>
<VTU>
<USN>USN:1AH10CS037</USN>
<name>NAME:SUHAAS</name>
<college>College:ACSCE</college>
<branch>Branch:CSE</branch>
<YOJ>Year of joining:2010</YOJ>
<email>E-mail:suhaas@gmail.com</email>
</VTU>

<VTU>
<USN>USN:1AH10CS033</USN>
<name>NAME:SANTU</name>
<college>College:ACSCE</college>
<branch>Branch:CSE</branch>
<YOJ>Year of joining:2009</YOJ>
<email>E-mail:santhu@gmail.com</email>
</VTU>
<VTU>
<USN>USN:1AH10CS034</USN>
<name>NAME:SHASHI</name>
<college>College:ACSCE</college>
<branch>Branch:CSE</branch>
<YOJ>Year of joining:2008</YOJ>
<email>E-mail:shashi@gmail.com</email>
</VTU>
</students>
4a.css)
students
{
background-color:white;width:100%;
}
VTU
{
display:block;color:blue;margin-bottom:30pt;margin-left:0;
}
USN
{
display:block;color:blue;font-size:15pt;margin-left:20pt;
}
name
{
display:block;color:green;font-size:15pt;margin-left:30pt;
}
college,branch,YOJ,email
{
display:block;color:red;font-size:15pt;margin-left:20pt;
}
4b.xml)
<?xml version = "1.0"?>
<?xml-stylesheet type = "text/xsl" href="4b.xsl"?>
<VTU>
<USN>1AH10CS037</USN>
<name>SUHAAS</name>
<college>ACSCE</college>
<branch>CSE</branch>
<YOJ>2010</YOJ>

<email>suhaas@gmail.com</email>
</VTU>
4b.xsl)
<?xml version = "1.0"?>
<xsl:stylesheet version = "1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="VTU">
<html><head><title>Style Sheet for 4b.xml</title></head>
<body>
<h2>VTU Student description</h2>
<span style="font-style:italic;color:blue;">USN:
</span>
<xsl:value-of select="USN"/><br/>
<span style="font-style:italic;color:blue;">Name:
</span>
<xsl:value-of select="name"/><br/>
<span style="font-style:italic;color:blue;">College:
</span>
<xsl:value-of select="college"/><br/>
<span style="font-style:italic;color:blue;">Branch:
</span>
<xsl:value-of select="branch"/><br/>
<span style="font-style:italic;color:blue;">YOJ:
</span>
<xsl:value-of select="YOJ"/><br/>
<span style="font-style:italic;color:blue;">E-mail:
</span>
<xsl:value-of select="email"/><br/>
</body></html>
</xsl:template></xsl:stylesheet>
5a.pl)
#!/usr/bin/perl
use CGI':standard';
print "content-type:text/html","\n\n";
print "<html>\n";
print "<head><title>About this server</title></head>\n";
print "<body><h1>About this server</h1>","\n";
print "<hr>";
print "Server name:",$ENV{'SERVER_NAME'},"<br>";
print "Running on port:",$ENV{'SERVER_PORT'},"<br>";
print "Server Software:",$ENV{'SERVER_SOFTWARE'},"<br>";
print "CGI-Revision:",$ENV{'GATEWAY_INTERFACE'},"<br>";
print "<hr>\n";
print "</body></html>\n";
exit(0);

5b.html)
<html>
<body>
<form action = "http://localhost/cgi-bin/5b.pl">
<input type = "text" name = "com">
<input type = "submit" value = "Submit">
</form>
</html>
5b.pl)
#!/usr/bin/perl
use CGI':standard';
print "content type:text/html \n\n";
$c=param('com');
system($c);
exit(0);
6a.pl)
#!/usr/bin/perl
use CGI':standard';
use CGI::Carp qw(warningsToBrowser);
@coins=("Welcome to Web Programming Lab","Have a nice time in lab","Practice all the
programs","well done Good day");
$range=4;
$random_number=int(rand($range));
if(param)
{
print header();
print start_html(-title=>"User name",-bgcolor=>"Pink",-text=>"blue");
$cmd=param("name");
print b("Hello $cmd,$coins[$random_number]"),br();
print start_form();
print submit(-value=>"Back");
print end_form();
print end_html();
}
else
{
print header();
print start_html(-title=>"Enter user name",-bgcolor=>"yellow",-text=>"blue");
print start_form(),textfield(-name=>"name",-value=>" "),submit(-name=>"submit",value=>"Submit"),reset();
print end_form();
print end_html();
}

6b.pl)
#!/usr/bin/perl
use CGI':standard';
use CGI::Carp qw(warningsToBrowser);
print header();

print start_html(-title=>"WebPage counter",-bgcolor=>"Pink",-text=>"blue");


open(FILE,'<count.text');
$count=<FILE>;
close(FILE);
$count++;
open(FILE,'>count.txt');
print FILE "$count";
print b("This page has been viewed $count times");
close(FILE);
print end_html();

7.pl)
#!/usr/bin/perl
use CGI':standard';
print "Refresh: 1\n";
print "content-type:text/html","\n\n";
print start_html(-title=>"Program 7",-bgcolor=>"Black",-text=>"white");
($s,$m,$h)=localtime(time);
print br,br,"The current system time is $h:$m:$s";
print br,br,hr,"In words $h hours $h minutes $s seconds";
print end_html;
8.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:cs2","root"," ");
$name=param("name");
$age=param("age");
$qh=$dbh->prepare("insert into stu values('$name','$age')");
$qh->execute();
$qh=$dbh->prepare("select * from stu");
$qh->execute();
print"<table border size=1><tr><th>name</th><th>age</th></tr>"
while(($name,$age)=$qh->fetchrow())
{
print"<tr><td>$name</td><td>$age></td></tr>";
}
print"</table>";
$gh->finish();
$dhb->disconnect();
print"</html">;
8.html)

<html>
<body>
<form action="http://localhost/cgi-bin/18.pl">
name:<input type ="text" name="name"><br>
age:<input type="text" name="age"><br>
<input type="submit" value="submit">

</form>
</html>
9.php)
<?php
date_default_timezone_set('asia/calcutta');
$in=60*60*24*60+time();
setcookie('lastvisit',date("G:i-->m/d/y"),$in);
if(isset($_COOKIE['lastvisit']))
{
$visit=$_COOKIE['lastvisit'];
echo"your last visit was-->",$visit;
}
else
echo"you have got failed cookie";
?>
10.php)
<?php
session_start();
session_register("count");
if(!isset($_SESSION))
{
$_SESSION["count"]=0;
echo"<p> counter initilized</p>\n";
}
else
{
$_SESSION["count"]++;
}
echo"<p> counter is row<b>$_SESSION[count]</b></p>",
"<p>reload this page to increament</p>";
?>
11main.html)
<?xml version = "1.0" eencoding= "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">
<body>
<h1>contact database</h1>
<FORM ACTION="11add.php" METHOD="POST">
<INPUT TYPE=submit VALUE="Add contact">
</FORM>
<FORM ACTION="11search.php" METHOD="POST">
<INPUT TYPE=submit VALUE="searcg contact">
</FORM>
</BODY>
</HTML>

11search.php)
<html>
<head><title>program 13</title></head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Enter name of the person<input type="text" name="name">
<input type=submit value=submit>
</form>
<form action="11main.html">
<?php
$link=mysql_connect("localhost","root","");
mysql_select_db("dbh");
$n=$_POST["name"];
if($_POST["name"]!=Null)
{
print "entered name is $n\n";
$var=mysql_query("SELECT * FROM contacts WHERE
name='{$_POST['name']}'");
echo"<table border size=1>";
echo"<tr> <th>name</th><th>Adress 1</th> <th>Adress2</th>
<th>E-mail</th></tr>";
while($arr=mysql_fetch_row($var))
{
echo "<tr><td>$arr[0]</td><td>$arr[1]</td><td>$arr[2]</td>
<td>$arr[3]</td></tr>";
}
echo"</table>";
mysql_free_result($var);
mysql_close($link);
}
?>
<BR>
</form>
<a href=http://localhost/11main.html> <br> <br> Back to main menu</a>
</body>
</html>
11add.php)
<html>
<body>
<h1>contact form</h1>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<p>
Name:<INPUT TYPE=text NAME="name" value=""> <BR>
Address 1:<INPUT TYPE=text NAME="addr1" value=""> <BR>
Address 2:<INPUT TYPE=text NAME="addr2" value=""> <BR>
email:<INPUT TYPE=text NAME="email" value=""> <BR>
<INPUT TYPE=submit VALUE=submit> <BR> <BR>
</FORM>

<?php
$self=$_SERVER['PHP_SELF'];
$dbh=mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('dbh') or die(mysql_error());
if(isset($_POST['name']))
{
$name=$_POST['name'];
$addr1=$_POST['addr1'];
$addr2=$_POST['addr2'];
$email=$_POST['email'];
if($name !="" && $addr1 !="")
{
$query="INSERT INTO contacts VALUES
('$name','$addr1','$addr2','$email')";
$result=mysql_query($query) or die(mysql_error());
echo "one contact added";
}
else
echo "one of the field is empty";
}
mysql_close($dbh);
echo "<a href=http://localhost/11main.html> <br> <br> Back to main menu</a>"
?>
</body>
</html>
12welcome.rhtml)
<html>
<head><title>Search.html</title></head>
<body>
<h1>Enter The Book Title to Search</h1>
<form action="result" method="post">
Title<input type="text" name="tit" size="20"/>
<input type="submit" value="search"/>
</form>
12search_controller.rb)
class SearchController < ApplicationController
def welcome
end
def result
@tit = params[:tit]
@bookz=Book.find(:all,:conditions=>["title=?",@tit])
end
end
12results.rhtml)
<html>

<head><title>result.html</title></head>
<body>
<h1>The details of the book with title <%= @tit %></h1>
<table border="border">
<tr>
<th>Title</th>
<th>Author</th>
<th>Publication</th>
<th>Edition</th>
</tr>
<% @bookz.each do |book|
@title = book.title
@author = book.author
@publication = book.publication
@edition = book.edition %>
<tr>
<td><%= @title %></td>
<td><%= @author %></td>
<td><%= @publication %></td>
<td><%= @edition %></td>
</tr>
<% end %>
</table>
<a href="http://localhost:3000/main/welcome">back</a>
</body>
</html>

S-ar putea să vă placă și