0% found this document useful (0 votes)
26 views27 pages

Wtlab Manual

Uploaded by

ranganadh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views27 pages

Wtlab Manual

Uploaded by

ranganadh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Web Technologies Lab

1 . HOME PAGE:
Source Code:

<html>

<head>

<frameset rows="20%,80%">

<frame src="F:\vinay\3-2\html\1.html" name="top">

<frameset cols="20%,80%">

<frame src="F:\vinay\3-2\html\2.html" name="left">

<frame src="F:\vinay\3-2\html\3.html" name="right">

</frameset>

</frameset>

</head>

</html>

1.html

<html>

<body bgcolor="pink">

<table border="1" height="84" width="1342" align="center">

<tr>

<th><img width="50" height="50" border="0" src="F:\vinay\photos\ucetglobe.jpg"></th></a>

<th><font face="Verdana" color="#ff0080">Universal Books Store</font></th>

</tr>

<tr><th><font face="Verdana"><a href="F:\vinay\3-2\html\home.html" target="right">

Home</a></font></th></a>

<th><a href="F:\vinay\3-2\html\login.html" target="right"><font


face="Verdana">Login</font></th></a>

<th><a href="F:\vinay\3-2\html\reg.html" target="right"><font


face="Verdana">Registration</font></th></a>

Universal College of Engineering and Technology


Web Technologies Lab

<th><a href="F:\vinay\3-2\html\catalogue.html" target="right"><font


face="Verdana">Catalogue</font></th></a>

<th><font face="Verdana">Cart</font></th>

</tr>

</table>

</body>

</html>

2.html

<html>

<body bgcolor="green">

<ol>

<font color="#ff8000"><a href="F:\vinay\3-2\html\cse.html" target="right">

<li>CSE</li></a></font>

<a href="F:\vinay\3-2\html\ece.html" target="right">

<li>ECE</li></a>

<a href="F:\vinay\3-2\html\mba.html" target="right">

<li>MBA</li></a>

</ol>

</body>

</html>

3.html

<html>

<body>

<h1><strong><font face="Verdana">

Description</font></strong></h1>

</body>

</html>

Universal College of Engineering and Technology


Web Technologies Lab

2. LOGIN PAGE:
Source Code:

<html>

<head>

<title>Login Page</title>

</head>

<body bgcolor="orange" background="C:\Documents and Settings\All Users\Documents\My


Pictures\Sample Pictures\Blue hills.jpg">

<br><br><br>

<table border=0 align="center">

<caption><h2>LOGIN</h2></caption>

<tr>

<td>Login:</td>

<td><input type="text" size="20"></td>

</tr>

<tr>

<td>Password:</td>

<td><input type="password" size="20"></td>

</tr>

<tr><td><input type="submit" value="Submit"></td>

<td><input type="reset" value="Reset"></td>

</tr>

</center>

</body>

</html>

Universal College of Engineering and Technology


Web Technologies Lab

3. CATOLOGUE PAGE:
Source Code:

<html>

<body bgcolor="orange">

<table border=1 align="left" width="980">

<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>

<th><input type="button" value="Add to cart"></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>

<th><input type="button" value="Add to cart"></th>

</tr>

<tr>

<th><img src="F:\vinay\photos\java2.jpg"

Universal College of Engineering and Technology


Web Technologies Lab

height="100" width="100"></th>

<th align="left"><h4><br></h4><h4>Book:Java 2<br>

Author:Watson<br>

Publication:BPB Publication<br></h4></th>

<th><h1>$35.5</h1></th>

<th><input type="button" value="Add to cart"></th>

</tr>

<tr>

<th><img src="F:\vinay\photos\html24.jpg"

height="100" width="100"></th>

<th align="left">Book:HTML in 24 hours<br>

Author:Sam Peter<br>

Publication:Sam<br></th>

<th><h1>$50</h1></th>

<th><input type="button" value="Add to cart"></th>

</tr>

</h1>

</table>

</body>

</html>

Universal College of Engineering and Technology


Web Technologies Lab

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++)

Universal College of Engineering and Technology


Web Technologies Lab

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>

Universal College of Engineering and Technology


Web Technologies Lab

5. Cascading Style Sheets


Source Code:

<html>

<head>

<title>Internal CSS</title>

<style>

body{background:"pink";}

h1{color:"green";}

p{font size="100";}

</style>

</head>

<body>

<h1>Welcome</h1>

<p>This is Internal CSS</p>

</body>

</html>

Universal College of Engineering and Technology


Web Technologies Lab

6. XML FILE
Source Code:

Books.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE Books SYSTEM "books.dtd">

<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>

Universal College of Engineering and Technology


Web Technologies Lab

Books.dtd

<!ELEMENT Books (INFORMATION)>

<!ELEMENT INFORMATION (Book1,Book2)>

<!ELEMENT Book1 (Book_name,Author_name,ISBN_no,publisher,edition,price)>

<!ELEMENT Book2 (Book_name,Author_name,ISBN_no,publisher,edition,price)>

<!ELEMENT Book_name (#PCDATA)>

<!ELEMENT Author_name (#PCDATA)>

<!ELEMENT ISBN_no (#PCDATA)>

<!ELEMENT publisher (#PCDATA)>

<!ELEMENT edition (#PCDATA)>

<!ELEMENT price (#PCDATA)>

Universal College of Engineering and Technology


Web Technologies Lab

7. Ruby program to calculate the factorial value of a number and prints the same
Source Code:

#!\usr\bin\ruby

#program to compute factorial

print "Enter any number:\n"

a=gets.chomp

n=a.to_i(base=10)

i=1

f=1

while i<=n

f=f*i;

i=i+1

end

print "factorial of #{a} is #{f}"

Universal College of Engineering and Technology


Web Technologies Lab

8. Ruby program to count number of lines in a text file using its regular
expressions facility.
Source Code:

#!\usr\bin\ruby

print "\nEnter the file name..:"

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

print "No of lines= #{c}"

Universal College of Engineering and Technology


Web Technologies Lab

9. Ruby program that uses iterator to find out the length of a string.
Source Code:

#find the length of given string

print "enter any string:\n"

s=gets.chop

a=Array.new

a=s.split("")

ct=0

for i in a

ct=ct+1

end

print "Length of string #{s} is : #{ct}"

Universal College of Engineering and Technology


Web Technologies Lab

10. Ruby program that uses arrays in Ruby


Source Code:

#prg on arrays

a=Array.new

print "Enter length of Array:\n"

i=gets.chop

n=i.to_i(base=10)

for i in 0..n-1

print "Enter element(#{i})..:"

r=gets.chop

a[i]=r.to_i

end

print "Array is...:\n"

for i in 0..n-1

print "#{a[i]}\n"

end

Universal College of Engineering and Technology


Web Technologies Lab

11. Ruby program that uses associative arrays concept of Ruby


Source Code:

#prg on associative arrays

a=Hash.new

print "Enter length of Hash:\n"

i=gets.chop

n=i.to_i(base=10)

for i in 0..n-1

print "Enter key element(#{i})..:"

key=gets.chop

print "Enter value element(#{i})..:"

r=gets.chop

a[key]=r.to_i(base=10)

end

print "Array is...:\n"

print "#{a}"

Universal College of Engineering and Technology


Web Technologies Lab

12. Ruby program that uses Math Module to find the area of a triangle.
Source Code:

#!\usr\bin\ruby

print "\n enter angle a...:"

a=gets.chop.to_i(base=10)

print "\n enter angle b...:"

b=gets.chop.to_i(base=10)

print "\n enter angle c...:"

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)

puts "area of a triangle is..#{area.ceil}"

Universal College of Engineering and Technology


Web Technologies Lab

13. Ruby program that uses tk module to display a window


Source Code:

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

variable1.value = "Enter any text value"

variable2.value = "Enter any confidential value"

entry1.place('height' => 25,

'width' => 150,

'x' => 10,

'y' => 10)

entry2.place('height' => 25,

'width' => 150,

'x' => 10,

'y' => 40)

Tk.mainloop

Universal College of Engineering and Technology


Web Technologies Lab

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

Universal College of Engineering and Technology


Web Technologies Lab

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 _)

print "\n$i is a text file";

if(-b _)

print "\n$i is a block special file";

if(-c _)

print "\n$i is a character special file";

else

print "$i doesn't exists";

Universal College of Engineering and Technology


Web Technologies Lab

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->do("create table faculty(name varchar(20),address varchar(20),phoneno int(10))");

$dbh->disconnect;

To Insert values:

use DBI;

my $dbh=DBI->connect("DBI:mysql:student","root","");

$dbh->do("insert into faculty values('Kishoresir','Guntur','521')");

$dbh->disconnect;

To retrieve values using ‘select’ command:

use DBI;

my $dbh=DBI->connect("DBI:mysql:student","root","");

$dbh->do("insert into faculty values('Kishoresir','Guntur','521')");

$dbh->disconnect;

Universal College of Engineering and Technology


Web Technologies Lab

17. PHP program for Contact Us page.


Source Code:

<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 "\nLast Date to Apply:11-03-2016";

print "\nmail:[email protected]";

print "\nPhone no:0863232231";

print "\nLocation:Universal College of Engineering and Technology

\nDokiparru\nGuntur";

?>

</body>

</html>

Universal College of Engineering and Technology


Web Technologies Lab

18. User Authentication:


Source Code:

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"]))

Universal College of Engineering and Technology


Web Technologies Lab

{
$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

align='center'>Your are not

an authenticated user</h1>";

}
?>
</body>
</html>

Universal College of Engineering and Technology


Web Technologies Lab

19. Shopping Cart:


Source Code:

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>".

"<td> {$r['name']} </td>".


"<td> {$r['desc']} </td>".
"<td>Rs{$r['price']} </td>".
"<td><img src='images/{$r['imgn']}'> </td>".
"<td width=2><input type='text' name='qty' maxlength='2' value='1'></td>".
"<td><button type='submit' class='add_cart'><img src='images/acrt.jpg'></button>".
"<td><input type='hidden' name='code' value='{$r['code']}'>".
"<input type='hidden' name='type' value='add' />".

Universal College of Engineering and Technology


Web Technologies Lab

"<input type='hidden' name='return_url' value='{$current_url}'/>".


"</td></td></form></tr> ";
}
echo "</table>";

}
?>
</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>

Universal College of Engineering and Technology


Web Technologies Lab

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);
?>

Universal College of Engineering and Technology


Web Technologies Lab

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>

Universal College of Engineering and Technology

You might also like