You are on page 1of 23

<?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"> <! lab1a.

html --> <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 + " Fibonocci 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>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab1a.txt[17-May-13 8:44:43 PM]

<?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"> <! lab1b.html A trivial document --> <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){ msgstr="Number and its Squares are \n"; for(i=1;i <= num; i++) { msgstr = msgstr + i + " - " + i*i + "\n"; } alert(msgstr) } else alert("No input supplied"); </script> </body> </html>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab1b.txt[17-May-13 8:44:44 PM]

<?xml version = "1.0" encoding = "utf-8" ?> <! lab2a.html --> <!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("US Number should be in DAADDAADDD format"); elem1.focus(); return false; } alert("US Number 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>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab2a.txt[17-May-13 8:44:44 PM]

<?xml version = "1.0" encoding = "utf-8" ?> <! lab2b.html --> <!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]$/ 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("US Number should be in DAADDAADDD format"); elem1.focus(); return false; } alert("US Number 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] format : <input type='text' name='req2'/> <BR/> <input type='submit' value='Check Field' />

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab2b.txt[17-May-13 8:44:44 PM]

</form> </body> </html>

file:///Gif41h%20lab/wp%20collage%20exec/untitled%20folder/wplab2b.txt[l7-May-13 8:44:44 PM]

<html> <head> <title> Lab3a</title> <script type="text/javascript"> var top="p1"; 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"> p.doc1{position:absolute;top:100px;left:200px;width:300px; z-index:0;background:red;border-style:solid;} p.doc2{position:absolute;top:120px;left:220px;width:300px; z-index:0;background:green;border-style:solid;} p.doc3{position:absolute;top:140px;left:240px;width:300px; z-index:0;background:yellow;border-style:solid;} </style> </head> <body bgcolor="indigo"> <p class="doc1" id="p1" onMouseOver="toTop('p1')"> This is first Para <br> This is first Para <br> This is first Para <br> </p> <p class="doc2" id="p2" onMouseOver="toTop('p2')"> This is second Para <br> This is second Para <br> This is second Para <br> </p> <p class="doc3" id="p3" onMouseOver="toTop('p3')"> This is Third Para <br> This is Third Para <br> This is Third Para <br> </p> </body> </html>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab3a.txt[17-May-13 8:44:45 PM]

<html> <head> <title> Lab3a</title> <script type="text/javascript"> var top="p1"; 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"> p.doc1{position:absolute;top:100px;left:200px;width:300px; z-index:0;background:red;border-style:solid;} p.doc2{position:absolute;top:120px;left:220px;width:300px; z-index:0;background:green;border-style:solid;} p.doc3{position:absolute;top:140px;left:240px;width:300px; z-index:0;background:yellow;border-style:solid;} </style> </head> <body bgcolor="indigo"> <p class="doc1" id="p1" onMouseOver="toTop('p1')"onMouseOut=toTop('p3')> This is first Para <br> This is first Para <br> This is first Para <br> </p> <p class="doc2" id="p2" onMouseOver="toTop('p2')" onMouseOut=toTop('p3')> This is second Para <br> This is second Para <br> This is second Para <br> </p> <p class="doc3" id="p3" onMouseOver="toTop('p3')" onMouseOut=toTop('p3')> This is Third Para <br> This is Third Para <br> This is Third Para <br> </p> </body> </html>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab3b.txt[17-May-13 8:44:45 PM]

<?xml version = "1.0"?> <!-- 4a.xsl An XSLT Stylesheet for 4a.xml using templates --> <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 wplab4a.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;"> Year of Join: </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>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab4a%20(2).txt[17-May-13 8:44:45 PM]

<?xml version"1.0"?< <?xml-stylesheet type"text/xsl" href"wplab4a.xsl" ?< <VTU< <USN< 1RN08ISE </USN< <name< Amar </name< <college< RNSIT </college< <branch< ISE </branch< <YOJ< 2007 <IYOJ< <email< amar@gmail.com </email< <!VTU<

file:///Gif41h%20lab/wp%20collage%20exec/untitled%20folder/wplab4a.txt[17-May-13 8:44:45 PM]

<?xml version = "1.0"?> <!-- 4a.xsl --> <xsl:stylesheet version = "1.0" xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" xmlns = "http://www.w3.org/1999/xhtml" > <xsl:template match = "students"> <h2> VTU Students' Descriptions </h2> <xsl:for-each select = "VTU"> <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;"> Year of Join: </span> <xsl:value-of select = "YOJ" /> <br /> <span style = "font-style: italic; color: blue;"> E-Mail: </span> <xsl:value-of select = "email" /> <br /> <br /> </xsl:for-each> </xsl:template> </xsl:stylesheet>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab4b%20(2).txt[17-May-13 8:44:46 PM]

<?xml version = "1.0"?> <!-- 4a.xml --> <?xml-stylesheet type = "text/xsl" href = "wplab4b.xsl" ?> <students> <VTU> <USN> 1RN08IS001 </USN>4 <name> Amar </name> <college> RNSIT </college> <branch> ISE</branch> <YOJ> 2008 </YOJ> <email> amar@gmail.com </email> </VTU> <VTU> <USN> 1RN08IS002</USN> <name> asha</name> <college> RNSIT </college> <branch> ISE </branch> <YOJ> 2008 </YOJ> <email> asha@rnsit.in </email> </VTU> <VTU> <USN> 1RN08IS003 </USN> <name> Bhavya </name> <college> RNSIT </college> <branch> ISE </branch> <YOJ> 2008</YOJ> <email> bhavya@yahoo.com </email> </VTU> </students>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab4b.txt[17-May-13 8:44:46 PM]

#!/usr/bin/perl use CGI':standard'; # 5a.pl 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);

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab5a.txt[17-May-13 8:44:46 PM]

<html> <body> <form action "http://localhost/cgi-bin/wplab5b.pl">


<input type="text" name="com">

<input type"submit" value"Submit"> </form> </html>

file:///Gif41h%20lab/wp%20collage%20exec/untitled%20folder/wplab5b. txt[17- May-13 8:44:46 PM]

#!/usr/bin/perl use CGI':standard'; print "content-type: text/html \n\n"; $c param('com'); system($c); exit(O);

file:///Gif41h%20lab/wp%20collage%20exec/untitled%20folder/wplab5b2 .txt[ 17-May-13 8:44:46 PM]

#!/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(); }

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab6a.txt[17-May-13 8:44:47 PM]

#!/usr/bin/perl use CGI':standard'; use CGI::Carp qw(warningsToBrowser);

print header(); print start_html(-title=>"WebPage Counter", open(FILE,'<count.txt'); $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();

-bgcolor=>"Pink",-text=>"blue");

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab6b.txt[17-May-13 8:44:47 PM]

#!/usr/bin/perl use CGI ':standard'; print "Refresh: 1\n"; print "Content-Type: text/html\n\n"; print start_html(-title=>"Program 8",-bgcolor=>"green", -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 $m minutes $s seconds"; print end_html;

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab7t[17-May-13 8:44:47 PM]

<html> <body> <form action "http://localhost/cgi-bin/wplab8. pi"> Name :<input type "text" name "name"> <br> Age :<input type "text" name"age"> <br> <input type"submit" value"Submit"> </form> </html>

file:///Gif41h%20lab/wp%20collage%20exec/untitled%20folder/wplab8 .txt[ 17-May-13 8:44:47 PM]

<?php date_default_timezone_set('Asia/Calcutta'); //Calculate 60 days in the future //seconds * minutes * hours * days + current time $inTwoMonths = 60 * 60 * 24 * 60 + time(); setcookie('lastVisit', date("G:i - m/d/y"), $inTwoMonths); if(isset($_COOKIE['lastVisit'])) { $visit = $_COOKIE['lastVisit']; echo "Your last visit was - ". $visit; } else echo "You've got some old cookies!"; ?>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab9t[17-May-13 8:44:47 PM]

<?php $xmlstr = <<<XML <?xml version="1.0" standalone="yes"?> <student_details> <student> <stud_name> ABCD </stud_name> <stud_usn> 1234 </stud_usn> <stud_branch> MCA </stud_branch> </student> <student> <stud_name> EFGH </stud_name> <stud_usn> 5678 </stud_usn> <stud_branch> MBA </stud_branch> </student> </student_details> XML; ?>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab10a.txt[17-May-13 8:44:48 PM]

<?php include 'wplab10a.php'; $xml = new SimpleXMLElement($xmlstr); echo $xml->getName() . "<br />"; echo 'multiple values: <br />'; $link=mysql_connect("localhost","root",""); mysql_select_db("aman"); foreach ($xml->student as $student) { echo $student->stud_name . '<br />'; echo $student->stud_usn . '<br />'; echo $student->stud_branch . '<br />'; echo '<br />'; $t=mysql_query("insert into student values('$student->stud_name','$student->stud_usn','$student->stud_branch')"); }

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab10b.txt[17-May-13 8:44:48 PM]

<html> <head> <title> A program to get values from database </title></head> <body> <form action "wplablld.php" method "post"> Enter Name of the person <input type "text" name "name" /> <input type"submit" value"submit" /> </form> </body></html>

file:///Gif41h%20lab/wp%20collage%20exec/untitled%20folder/wplabl0c.txt[l7-May-13 8:44:48 PM]

<html> <-- 11a.php --> <body> <?php $self = $_SERVER['PHP_SELF']; $dbh = mysql_connect('localhost', 'root', "", 'adi') or die(mysql_error()); mysql_select_db('adi') or die(mysql_error()); if(isset($_POST['name'])) { $nme = $_POST['name']; $ad1 = $_POST['add1']; $ad2 = $_POST['add2']; $eml = $_POST['email']; if($nme != "" && $ad1 != "") { $query = "INSERT INTO contact VALUES ('$nme', '$ad1', '$ad2', '$eml')"; $result = mysql_query($query) or die(mysql_error()); } else echo "one of the field is empty"; } mysql_close($dbh); ?> <FORM ACTION="<?=$self?>" METHOD="POST"> <P> Name: <INPUT TYPE=text NAME="name" value=""> <BR> Address 1:<INPUT TYPE=text NAME="add1" value=""><BR> Address 2:<INPUT TYPE=text NAME="add2" value=""><BR> email:<INPUT TYPE=text NAME="email" value=""><BR> <INPUT TYPE=submit> </FORM> </body> </html>

file:///G|/4th%20lab/wp%20collage%20exec/untitled%20folder/wplab11a%20(2).txt[17-May-13 8:44:48 PM]

You might also like