Wtlab Manual
Wtlab Manual
1 . HOME PAGE:
Source Code:
<html>
<head>
<frameset rows="20%,80%">
<frameset cols="20%,80%">
</frameset>
</frameset>
</head>
</html>
1.html
<html>
<body bgcolor="pink">
<tr>
</tr>
Home</a></font></th></a>
<th><font face="Verdana">Cart</font></th>
</tr>
</table>
</body>
</html>
2.html
<html>
<body bgcolor="green">
<ol>
<li>CSE</li></a></font>
<li>ECE</li></a>
<li>MBA</li></a>
</ol>
</body>
</html>
3.html
<html>
<body>
<h1><strong><font face="Verdana">
Description</font></strong></h1>
</body>
</html>
2. LOGIN PAGE:
Source Code:
<html>
<head>
<title>Login Page</title>
</head>
<br><br><br>
<caption><h2>LOGIN</h2></caption>
<tr>
<td>Login:</td>
</tr>
<tr>
<td>Password:</td>
</tr>
</tr>
</center>
</body>
</html>
3. CATOLOGUE PAGE:
Source Code:
<html>
<body bgcolor="orange">
<tr>
<th><img src="F:\vinay\photos\xml.jpg"
height="100" width="100"></th>
<th><h4><br></h4><h4 align="left">Book:XML<br>
Author:Winston<br>
Publication:Wiely<br></h4></th>
<th><h1>$40.5</h1></th>
</tr>
<tr>
<th><img src="F:\vinay\photos\ai.jpg"
height="100" width="100"></th>
<th align="left"><h4><br></h4><h4>
Book:AI<br>
Author:S.Russel<br>
Publication:Princeton<br></h4></th>
<th><h1>$63</h1></th>
</tr>
<tr>
<th><img src="F:\vinay\photos\java2.jpg"
height="100" width="100"></th>
Author:Watson<br>
Publication:BPB Publication<br></h4></th>
<th><h1>$35.5</h1></th>
</tr>
<tr>
<th><img src="F:\vinay\photos\html24.jpg"
height="100" width="100"></th>
Author:Sam Peter<br>
Publication:Sam<br></th>
<th><h1>$50</h1></th>
</tr>
</h1>
</table>
</body>
</html>
4. REGISTRATION PAGE:
Source Code:
<html><head>
<title>Registration Form</title>
</head>
<body bgcolor="red" background="C:\Documents and Settings\All Users\
Documents\My Pictures\Sample Pictures\Sunset.jpg">
<table border="0" align="center">
<caption>ONLINE REGISTRATION</caption>
<tr><td>Name: </td><td><input type="text" size="20"> </td></tr>
<tr><td>Password: </td><td><input type="password" size="20"></td></tr>
<tr><td>E-Mail ID: </td><td><input type="text" size="30"></td></tr>
<tr><td>Phone Number: </td><td><input type="text" size="10"></td></tr>
<tr><td>Gender: </td><td>Male:<input type="radio" value="male">
Female:<input type="radio" value="female"> </td></tr>
<tr><td>Date Of Birth: </td>
<td><select name="Day">
<option value="Day">Day</option>
<script type="text/javascript">
for(b=1;b<=31;b++)
document.write("<option value="+b+">"+b+"</option>");
</script>
</select>
<select name="Month">
<option value="Mon">Month</option>
<option value="j">January</option>
<option value="f">Febrauary</option>
<option value="m">March</option>
<option value="a">April</option>
<option value="my">May</option>
<option value="j">June</option>
<option value="jy">July</option>
<option value="au">August</option>
<option value="sp">September</option>
<option value="o">October</option>
<option value="n">November</option>
<option value="d">December</option>
</select>
<select name="year">
<option value="year">Year</option>
<script type="text/javascript">
for(b=1970;b<=2020;b++)
document.write("<option value="+b+">"+b+"</option>");
</script>
</select> </td></tr>
<tr><td>Languages Known: </td><td>
<input type="checkbox" Name="English">English
<input type="checkbox" Name="Telugu">Telugu
<input type="checkbox" Name="Hindi">Hindi
<input type="checkbox" Name="Tamil">Tamil </td></tr>
<tr><td>Address: </td>
<td><textarea rows="6" cols="20" name="Address">
</textarea> </td></tr>
<tr><td><input type="submit" name="submit" value="register"></td>
<td><input type="reset" name="clear" value="clear"></td></tr>
</table>
</body>
</html>
<html>
<head>
<title>Internal CSS</title>
<style>
body{background:"pink";}
h1{color:"green";}
p{font size="100";}
</style>
</head>
<body>
<h1>Welcome</h1>
</body>
</html>
6. XML FILE
Source Code:
Books.xml
<Books>
<INFORMATION>
<Book1>
<Book_name>Java Script</Book_name>
<Author_name>Balanji Badam</Author_name>
<ISBN_no>521</ISBN_no>
<publisher>TATA Publications</publisher>
<edition>1st Edition</edition>
<price>1950</price>
</Book1>
<Book2>
<Book_name>HTML in 24 hours</Book_name>
<Author_name>Kishore Babu</Author_name>
<ISBN_no>504</ISBN_no>
<publisher>UCET Publications</publisher>
<edition>2nd Edition</edition>
<price>2000</price>
</Book2>
</INFORMATION>
</Books>
Books.dtd
7. Ruby program to calculate the factorial value of a number and prints the same
Source Code:
#!\usr\bin\ruby
a=gets.chomp
n=a.to_i(base=10)
i=1
f=1
while i<=n
f=f*i;
i=i+1
end
8. Ruby program to count number of lines in a text file using its regular
expressions facility.
Source Code:
#!\usr\bin\ruby
fname=gets.chop
f=File.new(fname,'r')
c=0
reg=/\n/
while !f.eof?
buf=""
f.read(1,buf)
if reg.match(buf)
c=c+1
end
end
9. Ruby program that uses iterator to find out the length of a string.
Source Code:
s=gets.chop
a=Array.new
a=s.split("")
ct=0
for i in a
ct=ct+1
end
#prg on arrays
a=Array.new
i=gets.chop
n=i.to_i(base=10)
for i in 0..n-1
r=gets.chop
a[i]=r.to_i
end
for i in 0..n-1
print "#{a[i]}\n"
end
a=Hash.new
i=gets.chop
n=i.to_i(base=10)
for i in 0..n-1
key=gets.chop
r=gets.chop
a[key]=r.to_i(base=10)
end
print "#{a}"
12. Ruby program that uses Math Module to find the area of a triangle.
Source Code:
#!\usr\bin\ruby
a=gets.chop.to_i(base=10)
b=gets.chop.to_i(base=10)
c=gets.chop.to_i(base=10)
sum=a+b+c
s=sum/2
t1=(s-a).abs
t2=(s-b).abs
t3=(s-c).abs
area=Math.sqrt(s*t1*t2*t3)
require 'tk'
root = TkRoot.new
root.title = "Window"
entry1 = TkEntry.new(root)
entry2 = TkEntry.new(root) do
show '*'
end
variable1 = TkVariable.new
variable2 = TkVariable.new
entry1.textvariable = variable1
entry2.textvariable = variable2
Tk.mainloop
14. Ruby program to define complex class and do write methods to carry
operations on complex objects.
Source Code:
class Ex
def initialize(v1,v2,v3)
@a=v1
@b=v2
@c=v3
end
def display
puts "...#{@a}...#{@b}...#{@c}"
end
end
d=Ex.new(4,21,43)
d.display
15. Perl program that takes a set names along command line and prints
whether they are regular or special files.
Source Code:
foreach my $i(@ARGV)
if(-e $i)
if(-T _)
if(-b _)
if(-c _)
else
16. Perl program to connect to a MYSQL database table and executing simple
commands.
Source Code:
To Create Table:
use DBI;
my $dbh=DBI->connect("DBI:mysql:student","root","");
$dbh->disconnect;
To Insert values:
use DBI;
my $dbh=DBI->connect("DBI:mysql:student","root","");
$dbh->disconnect;
use DBI;
my $dbh=DBI->connect("DBI:mysql:student","root","");
$dbh->disconnect;
<html>
<head>
<title>
Invitation
</title>
</head>
<body>
UNIQUEST2K16
<a href="contactus.php">For more information contact us</a>
</body>
</html>
contactus.php
<html>
<head>
<title>
Contact Us</title>
</head>
<body>
<?php
print "\nmail:[email protected]";
\nDokiparru\nGuntur";
?>
</body>
</html>
i)
<?php
setcookie("user1","pwd1",time()+3600,"/","",0);
setcookie("user2","pwd2",time()+3600,"/","",0);
setcookie("user3","pwd3",time()+3600,"/","",0);
setcookie("user4","pwd4",time()+3600,"/","",0);
?>
<html>
<head>
<title> Cookies with PHP</title>
</head>
<body bgcolor="lightyellow" text="blue">
<h1 align="center">UNIVERSAL COLLEGE OF ENGINEERING AND TECHNOLOGY</h1>
<form action="http://localhost:8050/validate.php" method="post">
<table border=0 align="center">
<tr>
<td>user name </td>
<td> <input type="text" name="name"> </td>
</tr>
<tr>
<td>password </td>
<td> <input type="password" name="pwd"> </td>
</tr>
<tr>
<td><input type="submit" name="submit" value="login"> </td>
<td><input type="reset" name="clear" value="clear"> </td>
</tr>
</table>
</form>
</body>
ii)
<html>
<head>
<title>Accessing Cookies with PHP</title>
</head>
<body>
<?php
if( isset($_COOKIE["user1"]) &&isset($_COOKIE["user2"]) &&isset($_COOKIE["user3"])
&&isset($_COOKIE["user4"]))
{
$pwd1=$_COOKIE["user1"];
$pwd2=$_COOKIE["user2"];
$pwd3=$_COOKIE["user3"];
$pwd4=$_COOKIE["user4"];
$n=$_POST["name"];
$p=$_POST["pwd"];
if(($n=="user1") && ($p==$pwd1))
{
echo "Welcome $n";
}
elseif(($n=="user2") && ($p==$pwd2))
{
echo "Welcome $n";
}
elseif(($n=="user3") && ($p==$pwd3))
{
echo "Welcome $n";
}
elseif(($n=="user4") && ($p==$pwd4))
{
echo "Welcome $n";
}
else
echo "\n <h1
an authenticated user</h1>";
}
?>
</body>
</html>
i)
<htm l>
<head>
<style type="text/css">
table.t1{ border:1px solid #73AD21;}
table.t2{ border:1px solid #73AD21;}
td{border:1px solid #73AD21;}
th{border:1px solid #73AD29;}
div.relative {
position: relative;
width: 600px;
height: 400px;
}
div.absolute {
position: absolute;
top:10px;
right: 0;
width: 300px;
height: 100px;
}
</style>
</head>
<body>
<div class="relative">
<?php
session_start();
include_once("conl.php");
$current_url = urlencode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
$sq="select * from plist";
$rs=mysql_query($sq,$con);
echo "<h2 align='center'>UNIVERSAL ONLINE BOOK STORE</h2>";
if($rs)
{
echo "<table class='t1' align='left'><tr><th>ID</th><th>NAME</th";
echo "><th>DESCRIPTION</th><th>PRICE</th><th>image</th><th>Quantity</th></tr>";
while($r=mysql_fetch_array($rs,MYSQL_ASSOC))
{
echo "<tr><form method='post' action='update.php'> <td> {$r['id']} </td>".
}
?>
</div>
<div class="absolute">
<h2>Your Shopping Cart</h2>
<?php
if(isset($_SESSION["products"]) && count($_SESSION["products"])>0)
{
echo '<div class="viewtable">';
echo '<form method="post" action="update.php">';
echo '<table class="t2" width="100%" cellpadding="6" cellspacing="0">';
echo '<tbody>';
$total =0;
$b = 0;
foreach ($_SESSION["products"] as $item)
{
$name = $item["name"];
$qty = $item["qty"];
$price = $item["price"];
$code = $item["code"];
echo '<tr>';
echo '<td>Qty <input type="text" size="2" maxlength="2" name="qty['.$code.']" value="'.$qty.'"
/></td>';
echo '<td>'.$name.'</td>';
echo '<td><input type="checkbox" name="removeitem[]" value="'.$code.'" /> Remove</td>';
echo '</tr>';
$subtotal = ($price * $qty);
$total = ($total + $subtotal);
}
echo '<tr><td colspan="4">';
echo '<button type="submit">Update</button><a href="view.php"
class="button">Checkout</a>';
echo '</td></tr>';
echo '</tbody>';
echo '</table>';
$current_url = urlencode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
echo '<input type="hidden" name="return_url" value="'.$current_url.'" />';
echo '</form>';
echo '</div>';
}
?>
</div>
</body>
</html>
ii)
<?php
session_start();
include_once("conl.php");
if(isset($_POST["type"]) && $_POST["type"]=='add' && $_POST["qty"]>0)
{
foreach($_POST as $key => $value)
{
$list[$key] = filter_var($value, FILTER_SANITIZE_STRING);
}
unset($list["type"]);
unset($list["return_url"]);
$code=$list["code"];
$sq="select * from plist where code='$code'";
$rs=mysql_query($sq,$con);
if($rs)
{
while($r=mysql_fetch_array($rs,MYSQL_ASSOC))
{
$name=$r['name'];
$price=$r['price'];
$list["name"]=$name;
$list["price"]=$price;
if(isset($_SESSION["products"]))
{
if(isset($_SESSION["products"][$list['code']]))
{
unset($_SESSION["products"][$list['code']]);
}
}
$_SESSION["products"][$list['code']]= $list;
}
}
}
if(isset($_POST["qty"]) || isset($_POST["removeitem"]))
{
if(isset($_POST["qty"]) && is_array($_POST["qty"])){
foreach($_POST["qty"] as $key => $value){
if(is_numeric($value)){
$_SESSION["products"][$key]["qty"] = $value;
}
} }
if(isset($_POST["removeitem"]) && is_array($_POST["removeitem"])){
foreach($_POST["removeitem"] as $key){
unset($_SESSION["products"][$key]);
}
} }
$return_url = (isset($_POST["return_url"]))?urldecode($_POST["return_url"]):'';
header('Location:'.$return_url);
?>
iii)
<div class="view">
<form method="post" action="update.php">
<table>
<tr><th>Quantity</th><th>Name</th><th>Price</th><th>Total</th><th>Remove</th></tr>
<tbody>
<?php
session_start();
include_once("conl.php");
if(isset($_SESSION["products"]))
{
$total = 0;
$b = 0;
foreach ($_SESSION["products"] as $cartitem)
{
$name = $cartitem["name"];
$qty = $cartitem["qty"];
$price = $cartitem["price"];
$code = $cartitem["code"];
$subtotal = ($price * $qty);
echo '<tr>';
echo '<td><input type="text" size="2" maxlength="2" name="qty['.$code.']" value="'.$qty.'" /></td>';
echo '<td>'.$name.'</td>';
echo '<td>Rs'.$price.'</td>';
echo '<td>Rs'.$subtotal.'</td>';
echo '<td><input type="checkbox" name="removeitem[]" value="'.$code.'" /></td>';
echo '</tr>';
$total = ($total + $subtotal);
}
$grandtotal = $total + $shipping_cost;
foreach($taxes as $key => $value) {
$taxamount = round($total * ($value / 100));
$taxitem[$key] = $taxamount;
$grandtotal = $grandtotal + $taxamount; }
$listtax= '';
foreach($taxitem as $key => $value)
{ $listtax .= $key. ' : '. $currency. sprintf("%01.2f", $value).'<br />'; }
$shipping_cost = ($shipping_cost)?'Shipping Cost :Rs'.$shipping_cost.'<br />':'';
}
?>
<tr><td colspan="5"><span style="float:right;text-align: right;"><?php echo $shipping_cost. $listtax; ?
>Amount Payable : <?php echo sprintf("%01.2f", $grandtotal);?></span></td></tr>
<tr><td colspan="5"><a href="list.php" class="button">Add More Items</a><button
type="submit">Update</button></td></tr>
</tbody>
</table>
<input type="hidden" name="return_url" value="<?php
$current_url = urlencode($url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
echo $current_url; ?>" />
</form>
</div>