Web Programming Lab Manual 2009
Web Programming Lab Manual 2009
Develop and demonstrate a XHTML document that illustrates the use external style sheet,
ordered list, table, borders, padding, color, and the <span> tag.
p,table,li, // mystyle.css
{
font-family: "lucida calligraphy", arial, 'sans serif';
margin-left: 10pt;
}
p { word-spacing: 5px; }
body { background-color:rgb(200,255,205); }
td { padding: 0.5cm; }
th {
text-align:center;
font-size: 85%;
}
table
{
border-style: outset;
background-color: rgb(100,255,105);
}
li {list-style-type: lower-roman;}
span
{
color:blue;
background-color:pink;
font-size: 29pt;
font-style: italic;
font-weight: bold;
}
<table border="4" width="5%"> <!-- table with name & email -->
<tr>
<th width="204">Name </th>
<th>Email</th>
</tr>
<tr>
<td width="204">Dr. HNS</td>
<td>hns@gmail.com</td>
</tr>
<tr>
<td width="204">Dr. MKV</td>
<td>mkv@rediffmail.com</td>
</tr>
<tr>
<td width="204">Dr. GTR</td>
<td>gtr@rnsit.in</td>
</tr>
<tr>
<td width="204">Dr. MVS</td>
<td>mvs@hotmail.com</td>
</tr>
</table>
<hr> <!-- horizontal line -->
<ol> <!-- ordered list -->
<li> TSB Singh</li>
<li> Prakash S </li>
<li> manojKumar</li>
</ol>
<p>
<span>This is a text.</span> This is a text. This is a text. This
is a text. This is a text. This is a text. This is a text. This
is a text. This is a text. <span>This is a text.</span>
</p>
</body>
</html>
<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>
<!-- lab2b.html
A trivial document
-->
<head>
<script type="text/javascript">
function disp(num)
{
var alphaExp = /^[0-9]+$/;
if(!num.value.match(alphaExp))
{
alert("Input should be positive numeric");
return false;
}
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>
#!/usr/bin/perl
use CGI':standard'; # 6a.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);
#!/usr/bin/perl
use CGI':standard'; # 6b.pl
print "content type: text/html \n\n";
$c=param('com');
system($c);
exit(0);
#!/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();
}
#!/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.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();
#!/usr/bin/perl
($s,$m,$h)=localtime(time);
#! /usr/bin/perl
while ( ($name,$age)=$qh->fetchrow())
{
print "<tr><td>$name</td><td>$age</td></tr>";
}
print "</table>";
$qh->finish();
$dbh->disconnect();
print"</HTML>";
<html>
<body>
<form action="http://localhost/9.pl">
Name : <input type="text" name="name"> <br>
Age :<input type="text" name="age"> <br>
<input type="submit" value="Submit">
</form>
</html>
<?php
date_default_timezone_set('Asia/Calcutta');
$inTwoMonths = 60 * 60 * 24 * 60 + time();
if(isset($_COOKIE['lastVisit']))
{
$visit = $_COOKIE['lastVisit'];
echo "Your last visit was - ". $visit;
}
else
echo "You've got some stale cookies!";
?>
<?php
session_start();
session_register("count");
if (!isset($_SESSION))
{
$_SESSION["count"] = 0;
echo "<p>Counter initialized</p>\n";
}
else { $_SESSION["count"]++; }
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>
$n=$_POST["name"];
print "Entered Name is $n \n";