WEB PROGRAMMING

HTML PROGRAMS

DEPARTMENT OF IT 1 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO: 1

program:

Create a co-operate web page.Divide the browser screen into two frames.Frame on left
will be a menu consisting of hyperlinks.Clicking on anyone of these hyperlinks will lead
to a new page which must open in the frame on right hand side.

Code:

frame.html

<html>

<frameset cols="50,50">

<frame src="college.html">

<frame src="uty.html" name="main">

</frameset>

</html>

college.html

<html>

<head>

<title>SIST</title>

</head>

<body bgcolor="lightgreen">

<center>

<b>

<h1>Kannur University Campus</h1>

DEPARTMENT OF IT 2 III MCA LE 2016-18
WEB PROGRAMMING

<h2>Mangattuparamba</h2><br><br><br>

<a href="login.html" target="main">Login</a><br>

<a href="dept.html" target="main"> Departments</a><br>

<a href="img.html" target="main">Photos</a><br>

<a href="course.html" target="main">Course details</a><br>

</b>

</center>

</body>

</html>

login.html

<html>

<head>

<title>SIST</title>

</head>

<body bgcolor="lightgreen">

<center>

<b>

<h1>Login</h1>

</b>

<form>

<table align="center">

<tr><th>Username</th><th><input type="text"></th></tr>

<tr><th>Password</th><th><input type="password"></th></tr>

DEPARTMENT OF IT 3 III MCA LE 2016-18
WEB PROGRAMMING

</table>

</form>

</body>

</html>

dept.html

<html>

<head>

<title>SIST</title>

</head>

<body bgcolor="lightgreen">

<center>

<b><h2>Departments</h2>

<ul type="circle">

<tr><li>Department of Mathematics

<li>Department of Statistics

<li>Department of IT

<li>Department of History

<li>Department of Behavioural science

</ul>

</b>

</body>

</html>

DEPARTMENT OF IT 4 III MCA LE 2016-18
WEB PROGRAMMING

img.html

<html>

<head>

<title>SIST</title>

</head>

<body bgcolor="lightgreen">

<center>

<b>

<h1>Photos</h1>

<img src="foto.jpg" width="800" height="500">

</b>

<body>

</html>

course.html

<html>

<head>

<title>SIST</title>

</head>

<body bgcolor="lightgreen">

<center>

<b>

<h1>Kannur University Campus</h1>

<h2>Mangattuparamba</h2><br><br><br>

DEPARTMENT OF IT 5 III MCA LE 2016-18
WEB PROGRAMMING

<a href="login.html" target="main">Login</a><br>

<a href="dept.html" target="main"> Departments</a><br>

<a href="img.html" target="main">Photos</a><br>

<a href="course.html" target="main">Course details</a><br>

</b>

</center>

</body>

</html>

DEPARTMENT OF IT 6 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 7 III MCA LE 2016-18
WEB PROGRAMMING

DEPARTMENT OF IT 8 III MCA LE 2016-18
WEB PROGRAMMING

DEPARTMENT OF IT 9 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO:2

Program:

Create a table that contains marks of students, which use colspan and rowspan.

code:

<html>

<head>

<title>mark</title>

</head>

<body>

<center>

<h1><u>MARKLIST</u></h1>

<br><br><br><br><br><br>

<table border="1" align="center" bgcolor="pink" cellspacing="3" cellpadding="3">

<tr><th rowspan="3">Name</th></tr>

<tr><th colspan="3">Marks</th></tr>

<tr>

<th>SE</th>

<th>DBMS</th>

<th>CN</th>

</tr>

<tr>

<td>Anu</td>

<td>90</td>

<td>90</td>

DEPARTMENT OF IT 10 III MCA LE 2016-18
WEB PROGRAMMING

<td>90</td>

</tr>

<tr>

<td>Aju</td>

<td>80</td>

<td>91</td>

<td>95</td>

</tr>

<tr>

<td>Anna</td>

<td>80</td>

<td>70</td>

<td>80</td>

</tr>

<tr>

<td>Anju</td>

<td>90</td>

<td>90</td>

<td>90</td>

</tr>

</table>

</center>

</body>

</html>

DEPARTMENT OF IT 11 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 12 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO:3

Program:

Create a page with 2 links, one to the same page and to other page.

Code:

links.html

<html>

<head>

<title>links</title>

</head>

<body bgcolor="lightgreen">

<a href="#bottom">Click here to go to bottom of the page</a>

<h1><u>What is a system call</u></h1><br><br>

The operating system is responsible for<br><br>

Process Management (starting, running, stopping processes)<br><br>

File Management(creating, opening, closing, reading, writing, renaming files)<br><br>

Memory Management (allocating, deallocating memory)<br><br>

Other stuff (timing, scheduling, network management)<br><br>

An application program makes a system call to get the operating system to perform a
service for it, like reading from a file.<br><br>

The system call is the fundamental interface between an application and the Linux
kernel.<br><br><br>

<b><u>Process</u></b><br><br>

DEPARTMENT OF IT 13 III MCA LE 2016-18
WEB PROGRAMMING

When you execute a program on your UNIX system, the system creates a special
environment for that program. This environment<br> contains everything needed for the
system to run the program as if no other program were running on the system.<br>

Whenever you issue a command in UNIX, it creates, or starts, a new process. When you
tried out the ls command to list directory<br> contents, you started a process. A process,
in simple terms, is an instance of a running program.<br>

The operating system tracks processes through a five digit ID number known as the pid or
process ID . Each process in the <br>system has a unique pid.<br>

Pids eventually repeat because all the possible numbers are used up and the next pid rolls
or starts over. At any one time,<br> no two processes with the same pid exist in the
system because it is the pid that UNIX uses to track each process.<br>

<br>Starting a Process<br>

When you start a process (run a command), there are two ways you can run it <br>

<a href="fg.html">Foreground Processes</a><br>

Background Processes<br><br><br>

<a name="bottom">....End of the page....</a><br>

</body>

</html>

fg.html

<html>

<head>

<title>links</title>

</head>

<body bgcolor="lightgreen">

<h1>Foreground Process</h1><br><br><br>

<p>The process runs in the foreground, the output is directed to my screen, and if the ls
command wants any input (which it does not), it waits for it from the <br>

DEPARTMENT OF IT 14 III MCA LE 2016-18
WEB PROGRAMMING

keyboard.While a program is running in foreground and taking much time, we cannot run
any other commands (start any other processes) because prompt would not be
<br>available

until program finishes its processing and comes out.</p>

</body>

</html>

OUTPUT:

DEPARTMENT OF IT 15 III MCA LE 2016-18
WEB PROGRAMMING

DEPARTMENT OF IT 16 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO:4
Program :
Print Railway timetable
Code:
<html>

<head></head>

<body>

<form>

<table align="center" border="1" cellpading="2" bgcolor="#FFFFCC" width=800

height=500>

<tr>

<td colspan="6" align="center"><h2>TIME TABLE AND FARELIST</h2></td>

</tr><tr>

<td rowspan="2" align="center">Train name</td>

<td rowspan="2" align="center">Starting place</td>

<td rowspan="2" align="center">Destination</td>

<td colspan="2" align="center">Time</td>

<td colspan="2" align="center">Fare</td>

</tr><tr><td align="center">Arrival</td><td align="center">Departure</td><tr>

<tr>

<td rowspan="2" align="center">Malabar xpress</td>

DEPARTMENT OF IT 17 III MCA LE 2016-18
WEB PROGRAMMING

<td rowspan="2" align="center">Trivandrum</td>

<td rowspan="2" align="center">Mangalore</td>

<td colspan="2" align="center"></td>

<td colspan="2" align="center">120</td>

</tr>

<tr><td align="center">01.00</td><td align="center">10.00</td><tr>

<tr>

<td rowspan="2" align="center">Parasuram xpress</td>

<td rowspan="2" align="center">Mangalore</td>

<td rowspan="2" align="center">Chennai</td>

<td colspan="2" align="center"></td>

<td colspan="2" align="center">145</td></tr>

<tr><td align="center">7.20</td><td align="center">16.12</td></tr>

<tr>

<td rowspan="2" align="center">Egmore</td>

<td rowspan="2" align="center">Mangalore</td>

<td rowspan="2" align="center">Chennai</td>

<td colspan="2" align="center"></td>

<td colspan="2" align="center">145</td></tr>

<tr><td align="center">7.20</td><td align="center">16.12</td></tr>

DEPARTMENT OF IT 18 III MCA LE 2016-18
WEB PROGRAMMING

</table>

</form>

</body>

</html>

OUTPUT:

DEPARTMENT OF IT 19 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO:5
Program :
Create two links one for company profile and another for contact address of the company.

Code:
<html>

<body bgcolor ="pink">

<p align="center">

<font size=10><b>ANDROID COMPANY</b></font>

</p>

<center>

<a href="co.html"><h1>About Android</h1></a><br>

<ahref="cn.html"><h1>Contact</h1></a>

</center>

</body>

</html>

CO.HTML

<html>

<body bgcolor=#FFC99">

<font color="red">

<i><center><b><font size=15>ABOUT ANDROID..</font></b></center>

<h1>

<p align="left">

<br><br>

The mobile development community is at a tipping point. Mobile users demand more

choice, more opportunities to customize their phones, and more functionality. Mobile

DEPARTMENT OF IT 20 III MCA LE 2016-18
WEB PROGRAMMING

operators want to provide value-added content to their subscribers in a manageable and

lucrative way. Mobile developers want the freedom to develop the powerful mobile

applications users demand with minimal roadblocks to success. Finally, handset manufacturers

want a stable, secure, and affordable platform to power their devices. Upuntil now

single mobile platform has adequately addressed the needs of all the parties.

Enter Android, which is a potential game-changer for the mobile development community.

An innovative and open platform,Android is well positioned to address the

growing needs of the mobile marketplace.<br>

This explains what Android is, how and why it was developed, and where the

platform fits in to the established mobile marketplace.Memory was getting cheaper; batteries were
getting better; and PDAs and other

embedded devices were beginning to run compact versions of common operating systems

such as Linux and Windows.The traditional desktop application developer was suddenly

a player in the embedded device market, especially with Smartphone technologies

such as Windows Mobile, which they found familiar.

Handset manufacturers realized that if they wanted to continue to sell traditional

handsets, they needed to change their protectionist policies pertaining to handset design

and expose their internal frameworks, at least, to some extent.

A variety of different proprietary platforms emerged—and developers are still actively

creating applications for them. Some Smartphone devices ran Palm OS (now Garnet

OS) and RIM Blackberry OS. Sun Microsystems took its popular Java platform and

J2ME emerged (now known as Java Micro Edition [Java ME]). Chipset maker

Qualcomm developed and licensed its Binary Runtime Environment for Wireless

(BREW). Other platforms, such as Symbian OS, were developed by handset manufacturers

such as Nokia, Sony Ericsson, Motorola, and Samsung.The Apple iPhone OS (OS X

iPhone) joined the ranks in 2008.

DEPARTMENT OF IT 21 III MCA LE 2016-18
WEB PROGRAMMING

</p>

</h1>

</i>

</font>

</body>

</html>

CN.HTML

<html>

<body bgcolor="#FFCC99">

<font color="#CC3366">

<i>

<font size=10><center>Marshmallow Specification</center></font><b><br>

<h1>

Google now on tap<br>Android Pay<br>Type-c reverse charging<br>SystemUI
tuner<br>Animation and easter egg<br>Dark theme and rotation suppport</h1></i>

<h1>Contact us</h1>

2nd Street Bay Watch<br>2nd block<br>New York<br>0644-4466-44233

</font>

</body>

</html>

DEPARTMENT OF IT 22 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 23 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO:6
Program:

Create a page which makes use of HTML tags such as italic tag,center tag,paragraph
tag,break tag,font tag and its attributes.

Code:

<html>

<head>

<title>pgm</title>

</head>

<body bgcolor="lightgreen">

<h1><font face="Bodoni MT" color="green"><u><center>HTML AND
HTTP</center></u></font></h1>

<h3><u>HTTP</u></h3>

<p><font color="blue" size="5">HTTP is the common language that web browser and
web server used to communicate with each other on the internet.</font></p>

<h3><u><i>HTML</i></u></h3>

<p>The language used to develop web pages is called HTML.HTML is the language
interpreted by a browser.

Web pages are also called htmldocuments.HTML is a set of special codes that can be
embedded in text to add formatting and linking

information.HTML is specified as tags in an HTML document.

</body>

</html>

DEPARTMENT OF IT 24 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 25 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO :7

Program:

Design a webpage using image files.

Code:

<html>

<body>

<center><font face="Times New Roman"><font size=7>House</font><br>

<img src="house.jpg" width=100 height=100
border="3"></img></center><br><br>

<center><font size=7>Java cup </font align="left"></center><img src="java.jpg"
width=150 height=150 align="left"></img><h4>

<p>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp

java is a general purpose object oriented programming language developed by sun micro
system of USA in 1991.

Originally called oak by James Gosling . Java is a really simple, reliable, portable and
powerful language.

<p>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp

The most striking feature of the language is that it is a platform independent language.
Java features are compiled and interpreted.Platform independent and portable, object
oriented, robust and secure, distributed, multi threaded and interactive and element of java
language.</h4></p><br><br>

<font align="right"><center><font size=7>Computer<img src="computer.jpg"
align="right" width=100 height=100></img></font><br><h4>

DEPARTMENT OF IT 26 III MCA LE 2016-18
WEB PROGRAMMING

<p>&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
&nbsp &nbsp &nbsp &nbsp &nbsp

Computers are general purpose device that perform task or calculations according to a set
of instructions or programs. The first electronic digital computers developed between 1940
and 1945 in the UK and USA.

Computers are amazing, not only are they thousands of times faster, they can fit on your
desk, in your lap, or even in your pocket

The CPU is the most important component of a computer's hardware. The ALU and
Control unit together are termed as CPU. ALU performs arithmetic and logic operations.
CU interprets instructions and produce the respective control signals.</h4></font>

</p>

</body>

</html>

DEPARTMENT OF IT 27 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 28 III MCA LE 2016-18
WEB PROGRAMMING

PHP PROGRAMS

DEPARTMENT OF IT 29 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO.1
Program:

Print hello message and current date and time.

Code

<html>

<head>

<title>Hello</title>

</head>

</body>

<center><h1>

<?php

$d=date("D / M / Y");

date_default_timezone_set("Asia/Kolkata");

$t=date("h:i:s a");

echo "HELLO...Welcome to PHP..","<br>";

echo "Today is....","<br>";

echo $d."<br>";

echo $t;

?>

</h1></center>

</body>

</html>

DEPARTMENT OF IT 30 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 31 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO.2

Program:

Display greeting using if..else if.

Code:

<html>

<title>Greetings</title>

<body>

<center><br><br><h2>

<?php

date_default_timezone_set("Asia/Kolkata");

$t=date("H:i a");

if($t<12)

echo "Good Morning...";

elseif($t==12||$t==13)

echo"Good Afternoon...";

elseif($t>13&&$t<19)

echo"Eood Evening...";

else

echo"Good Night..."

?>

<h2></center>

</body>

</html>

DEPARTMENT OF IT 32 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 33 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM NO.3

Program:

Write a PHP script for displaying Fibonacci series

Code:

<html>

<title>Fibonacci Series</title>

<body

><h1><center>Fibonacci Series...<center></h1><br>

<form id="form1" name="form1" method="post" action="">

<table border="0" align="center">

<tr>

<td width="178"><h2>Enter the limit</h2></td>

<td width="278"><h1><input type="text" name="limit"></h1></td>

</tr>

<tr>

<td></td>

<td ><h1>

<input type="submit" name="submit" value="Find"></h1></td>

</tr>

</table>

<center><h3>

<?php

if(isset($_POST["submit"]))

DEPARTMENT OF IT 34 III MCA LE 2016-18
WEB PROGRAMMING

{

$m=0;

$r=1;

$l=$_POST['limit'];?><br>

<?php

if($l!=NULL)

{

echo "Fibonacci Series..";?><br>

<?php echo $m;?><br><?php

echo $r;?><br>

<?php

$s=2;

while($s<$l)

{

$t=$m+$r;

echo $t;

?><br>

<?php

$m=$r;

$r=$t;

$s++;

}

}

}

DEPARTMENT OF IT 35 III MCA LE 2016-18
WEB PROGRAMMING

?>

</center></h3></form>

</body>

</html>

OUTPUT:

DEPARTMENT OF IT 36 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 4

Program:

Write a script that count from 1 to 10 and display whether it is an even or odd number and
if it is a prime or not. Display this information within an html table.

Code:

<html>

<body><center>

<table border=”1”>

<tr><th>Number</th><th>Even</th><th>Odd</th><th>Prime</th></tr>

<?php

for($i=1;$i<=10;$i++)

{

$flag=0;

$n=$i%2;

?>

<tr><td>

<?php

echo $i;

?>

</td><td>

<?php

if($n==0)

echo 'yes';

DEPARTMENT OF IT 37 III MCA LE 2016-18
WEB PROGRAMMING

else

echo 'no';

?>

</td><td>

<?php

if($n==1)

echo 'yes';

else

echo 'no';

?>

</td><td>

<?php

for($j=2;$j<=$i/2;$j++)

{

if($i%$j==0)

{

$flag=1;

break;

}

}

if($flag==0)

echo 'yes';

else

echo 'no';

DEPARTMENT OF IT 38 III MCA LE 2016-18
WEB PROGRAMMING

?>

</td></tr>

<?php

}

?>

</table><center>

</body>

</html>

OUTPUT:

:

DEPARTMENT OF IT 39 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 5:

Program:

Print area of circle and rectangle.

Code:

<html>

<head>

<title>Area</title>

</head>

<body><center>

<form name="form1" method="post" action="">

<label><h1>.....Area.....</h1></label>

<table><tr><td><label>Enter radius </label></td>

<td><input name="txtrad" type="text"></td><tr>

<tr><td><label>Enter Length </label></td>

<td><input name="txtlen" type="text"></td></tr>

<tr><td><label>Enter bredth </label></td>

<td><input name="txtbre" type="text"></td></tr>

<tr><td></td><td></td></tr>

<tr><td><input name="circ" type="submit" value="Area of Circle"></td>

<td><input name="rect" type="submit" value="Area of Rectangle"></td></tr></table>

</center></form>

<?php

if(isset($_POST["circ"]))

DEPARTMENT OF IT 40 III MCA LE 2016-18
WEB PROGRAMMING

{

$rad=$_POST['txtrad'];

$area=$rad*3.14;

?><center>

<?php

echo "AREA OF CIRCLE: ".$area;

}

?></center>

<?php

if(isset($_POST["rect"]))

{

$len=$_POST['txtlen'];

$bre=$_POST['txtbre'];

$rectangle=$bre*$len;

?><center>

<?php

echo"AREA OF RECTANGLE: ".$rectangle;

}

?>

</body>

</html>

DEPARTMENT OF IT 41 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 42 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 6:

Program:

Write a php script for the following:design a form to accept 2 numbers from the user.Give
option to choose the arithematic operations(use radio button)display the result.

Code:

<html>

<form method="post">

<input type="text" placeholder="number 1" name="f1">

<br><br>

<input type="text" placeholder="number 2" name="f2">

<br><br>

<input type="radio" value="+" name="op"/>+

<br><br>

<input type="radio" value="-" name="op"/>-

<br><br>

<input type="radio" value="*" name="op"/>*

<br><br>

<input type="radio" value="/" name="op"/>/

<br><br>

<input type="submit" name="submit" value="calculate">

</form>

<?php

if(isset($_POST["submit"]))

{

DEPARTMENT OF IT 43 III MCA LE 2016-18
WEB PROGRAMMING

$a =$_POST["op"];

$n1=$_POST["f1"];

$n2=$_POST["f2"];

$flag=1;

$ans;

if($a=="+")

{

$ans=$n1+$n2;

}

else if($a=="-")

{

$ans=$n1-$n2;

}

else if($a=='/')

{

$ans=$n1/$n2;

}

else if($a=="*")

{

$ans=$n1*$n2;

}

else

{

echo "invalid";

$flag=0;

}

DEPARTMENT OF IT 44 III MCA LE 2016-18
WEB PROGRAMMING

if($flag!=0)

{

echo "Ans = ".$ans;

}

}

?>

</body>

</html>

OUTPUT:

DEPARTMENT OF IT 45 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 7:

Program:

Write a php script for the following. Design a form to accept the details of 3 different
items. Such as item code ,item name , unit sold ,rate ,display the bill in the tabular
format(Use only 4 text box).

Code:

Item.php

<html>

<body>

<form id="form1" name "form1" method="post" action="">

<p>&nbsp:</p>

<table width="353" borde="1" align="center">

<tr>

<td width="142">enter the item code</td>

<td><label>

<input type="text" name="code"/>

</label></td>

</tr>

<tr>

<td>enter item name</td>

<td><label>

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

</label></td>

DEPARTMENT OF IT 46 III MCA LE 2016-18
WEB PROGRAMMING

</tr>

<tr>

<td> unit sold</td>

<td><label>

<input type="text" name="unit"/>

</label></td>

</tr>

<tr>

<td>rate per one person</td>

<td><label>

<input type="text" name="rate"/>

</label></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><label>

<input type="submit" name="SUBMIT" value="submit"/>

<input type="submit" name="bill" value="bill"/>

</label></td>

</tr>

</table>

<p>&nbsp:</p>

</form>

</body>

DEPARTMENT OF IT 47 III MCA LE 2016-18
WEB PROGRAMMING

</html>

<?php

if($_POST['SUBMIT']!="")

{

$code=$_POST['code'];

$name=$_POST['name'];

$unit=$_POST['unit'];

$rate=$_POST['rate'];

$amount=$unit*$rate;

$con=mysql_connect("localhost","root","");

if(!$con)

{

echo"not connected";

}

mysql_select_db("item",$con);

$sql=mysql_query("insert into itemtable(code,name,unit,rate,amount) values
('".$_POST['code']."','".$_POST['name']."','".$_POST['unit']."','".$_POST['rate']."','".$amo
unt."')") or die(mysql_error()) ;

if($sel)

{

?>

<script type="text/javascript">

alert("added Successfully");

</script>

DEPARTMENT OF IT 48 III MCA LE 2016-18
WEB PROGRAMMING

<?php

}

mysql_close();

}

if($_POST['bill']!="")

header("location:itemm2.php")

?>

itemm2.php

<html>

<head></head>

<body>

<table width="424" border="1" align="center">

<tr>

<td width="55">item code</td>

<td width="78">item name</td>

<td width="58">unit sold</td>

<td width="109">rate</td>

<td width="90">amount</td>

</tr><tr>

<?php

$k=1;

DEPARTMENT OF IT 49 III MCA LE 2016-18
WEB PROGRAMMING

$r=1;

$amt1=0;

$con=mysql_connect("localhost","root","");

if(!$con)

{

echo"not connected";

}

mysql_select_db("item",$con);

//$sql1=mysql_query("insert into itemtable(amount) values ('".$_POST['amount']."')") or
die(mysql_error()) ;

$result=mysql_query("select * from itemtable");

while($row=mysql_fetch_array($result))

{

$amt=$row['unit']*$row['rate'];

?>

<td><?php echo $row['code']?></td>

<td><?php echo $row['name'];?></td>

<td><?php echo $row['unit'];?></td>

<td><?php echo $row['rate'];?></td>

<td><?php echo $amt;?></td>

</tr>

<?php

}

?>

<p>&nbsp;</p>

DEPARTMENT OF IT 50 III MCA LE 2016-18
WEB PROGRAMMING

<p>&nbsp;</p>

<p>

<?php

$sum=mysql_query("select sum(amount) from itemtable");

$r=mysql_fetch_array($sum)

?>

<tr>

<td width="55">&nbsp;</td>

<td width="78">&nbsp;</td>

<td width="58">&nbsp;</td>

<td width="109">total amount</td>

<td width="90"><?php echo $r['sum(amount)'];?></td>

</tr>

</table>

</p>

</body>

</html>

Item.sql

-- phpMyAdmin SQL Dump
-- version 4.5.1
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Mar 11, 2017 at 06:39 PM
-- Server version: 10.1.13-MariaDB
-- PHP Version: 5.6.23

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";

DEPARTMENT OF IT 51 III MCA LE 2016-18
WEB PROGRAMMING

SET time_zone = "+00:00";

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `item`
--

-- --------------------------------------------------------

--
-- Table structure for table `itemtable`
--

CREATE TABLE `itemtable` (
`id` int(11) NOT NULL,
`code` varchar(50) NOT NULL,
`name` varchar(50) NOT NULL,
`unit` varchar(50) NOT NULL,
`rate` varchar(50) NOT NULL,
`amount` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `itemtable`
--

INSERT INTO `itemtable` (`id`, `code`, `name`, `unit`, `rate`,
`amount`) VALUES
(1, '211', 'asd', '10', '10', '100'),
(3, '123', 'asdf', '12', '10', '120'),
(20, '789', 'asdfg', '40', '10', '400'),
(21, '123', 'pen', '50', '50', '2500');

-- --------------------------------------------------------

DEPARTMENT OF IT 52 III MCA LE 2016-18
WEB PROGRAMMING

--
-- Table structure for table `log1`
--

CREATE TABLE `log1` (
`id` int(11) NOT NULL,
`user` varchar(50) NOT NULL,
`pswd` varchar(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `itemtable`
--
ALTER TABLE `itemtable`
ADD PRIMARY KEY (`id`);

--
-- Indexes for table `log1`
--
ALTER TABLE `log1`
ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `itemtable`
--
ALTER TABLE `itemtable`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=22;
--
-- AUTO_INCREMENT for table `log1`
--

DEPARTMENT OF IT 53 III MCA LE 2016-18
WEB PROGRAMMING

ALTER TABLE `log1`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

OUTPUT:

DEPARTMENT OF IT 54 III MCA LE 2016-18
WEB PROGRAMMING

DEPARTMENT OF IT 55 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 8:

Program:

Write string design a form to accept 2 strings. Compare the 2 string using both
methods(== and strcmp function), append second string to the first string. accept second
string to the first string. Accept the position from the user: from where the character from
the are reversed.(use radio button).

Code:

<html>

<head>

</head>

<body>

<form id="form1" name="form1" method="post" action="">

<table width="468" border="0" align="center">

<tr>

<td width="314"><div align="center">Enter the 1st string:</dv></td>

<td width="144"><label>

<input type="text" name="s1"/>

</label></td>

</tr>

<tr>

<td><div align="center">Enter the 2nd string:</div></td>

<td><input type="text" name="s2"/></td>

</tr>

DEPARTMENT OF IT 56 III MCA LE 2016-18
WEB PROGRAMMING

<tr>

<td>Perform any one of the following operations</td>

<td>&nbsp;</td>

</tr>

<tr>

<td><label>

<input name="radiobutton" type="radio" value="oper" required/>

compare with==</label></td>

<td>&nbsp;</td>

</tr>

<tr>

<td><input name="radiobutton" type="radio" value="append"/>

append two string</td>

<td>&nbsp;</td>

</tr>

<tr>

<td><input name="radiobutton" type="radio" value="string"/>

Compare with strcmp()</td>

<td>&nbsp;</td>

</tr>

<tr>

<td height="28"><input name="radiobutton" type="radio" value="pos"/>

Give position to be reversed:</td>

<td>

DEPARTMENT OF IT 57 III MCA LE 2016-18
WEB PROGRAMMING

<label>

<input type="text" name="pos"/>

</label></td>

</tr>

<tr>

<td>&nbsp;</td>

<td>

<label>

<input type="submit" name="Submit" value="Submit"/>

</label></td>

</tr>

</table>

<p>&nbsp;</p>

<p>&nbsp;</p>

<p>&nbsp;</p>

</form>

<div align="center">

<?php

if(isset($_POST['Submit']))

{

$pos=$_POST['pos'];

$s1=$_POST['s1'];

$s2=$_POST['s2'];

$radio=$_POST['radiobutton'];

DEPARTMENT OF IT 58 III MCA LE 2016-18
WEB PROGRAMMING

if($radio=="oper")

{

if($s1==$s2)

{

echo "Strings are equal <br>";

}

else

{

echo "Strings are not equal <br>";

}}

else if($radio=="string")

{

$r=strcmp($s1,$s2);

if($r)

{

echo "Strings are not equal <br>";

}

else

{

echo "Strings are equal <br>";

}

}

else if($radio=="append")

{

DEPARTMENT OF IT 59 III MCA LE 2016-18
WEB PROGRAMMING

echo $s1.$s2;

}

else

{

$f=substr($s1,0,$pos);

$rev=strrev($f);

echo $rev;

}

}

?>

</div>

</body>

</html>

DEPARTMENT OF IT 60 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 61 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 9:

Program:

Create a form to accept student information name,class,address,mark for the subjects
physics,biology,chemistry,mathematics,Marathi,English.Display the mark sheet of the
students in the next page which contains name,class,marks,total and percentage.

Code:

mark.php

<html>

<title>Marks</title>

<head>

</head>

<body>

<form id="form1" name="form1" method="post" action="mark1.php">

<table width="287" border="0" align="center">

<tr>

<td colspan="2"><div align="center">

<p>&nbsp;</p>

<p><h2>Student Details</h2></p>

<p>&nbsp;</p>

</div></td>

</tr>

<tr>

<td width="85">Name</td>

DEPARTMENT OF IT 62 III MCA LE 2016-18
WEB PROGRAMMING

<td width="186">

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

</td>

</tr>

<tr>

<td>Class</td><td>

<input type="text" name="class"/>

</td>

</tr>

<tr>

<td height="66">Address</td>

<td>

<textarea name="textarea"></textarea></td>

</tr>

<tr>

<td colspan="2"><div align="center">

<p>&nbsp;</p>

<p><h2>Marks Obtained</h2></p>

<p>&nbsp;</p>

</div>

</td>

</tr>

<tr>

<td>Biology</td>

DEPARTMENT OF IT 63 III MCA LE 2016-18
WEB PROGRAMMING

<td><input type="text" name="bio"/>

</td>

</tr>

<tr>

<td>Physics</td>

<td><input type="text" name="phy"/>

</td>

</tr>

<tr>

<td>Chemistry</td>

<td><input type="text" name="che"/>

</td>

</tr>

<tr>

<td>Maths</td>

<td><input type="text" name="m"/>

</td>

</tr>

<tr>

<td>Marathi</td>

<td><input type="text" name="mara"/>

</td>

</tr>

DEPARTMENT OF IT 64 III MCA LE 2016-18
WEB PROGRAMMING

<tr>

<td>English</td><td>

<input type="text" name="eng"/>

</td>

</tr>

<tr></tr>

<tr><td></td>

<td>

<input name="ok" type="submit" value="Submit"/></td>

</td>

</tr>

</table>

</form>

</body>

</html>

mark1.php

<html>

<head></head>

<body>

<?php

$name=$_POST['name'];

$class=$_POST['class'];

$bio=$_POST['bio'];

$phy=$_POST['phy'];

DEPARTMENT OF IT 65 III MCA LE 2016-18
WEB PROGRAMMING

$che=$_POST['che'];

$m=$_POST['m'];

$mara=$_POST['mara'];

$eng=$_POST['eng'];

$tot=$bio+$phy+$che+$m+$mara+$eng;

$max=300;

$perc=($tot/$max)*100;

?>

<form action="" method="post"><center></center>

<table width="288" height="377" border="1" align="center">

<tr>

<td colspan="6"><h2><center>

<p>&nbsp;</p>

<p>..Student Details..</p>

</center></h2>

<div align="center">

</tr>

<tr>

<td colspan="3"> Name</td>

<td width="67" colspan="3"><?php echo $name;?></td>

</tr>

<tr>

<td colspan="3"> Class</td>

<td width="67" colspan="3"><?php echo $class;?></td>

DEPARTMENT OF IT 66 III MCA LE 2016-18
WEB PROGRAMMING

</tr>

<tr></tr>

<tr>

<td height="37" colspan="6"><div align="center">

Marks Obtained</div></td>

</tr>

<tr>

<td colspan="3">Biology</td>

<td colspan="3"><?php echo $bio;?></td>

</tr>

<tr>

<td colspan="3">Physics</td>

<td colspan="3"><?php echo $phy;?></td>

</tr>

<tr>

<td colspan="3">Chemistry</td>

<td colspan="3"><?php echo $che;?></td>

</tr>

<tr>

<td colspan="3">Maths</td>

<td colspan="3"><?php echo $m;?></td>

</tr>

<tr>

<td colspan="3">Marathi</td>

DEPARTMENT OF IT 67 III MCA LE 2016-18
WEB PROGRAMMING

<td colspan="3"><?php echo $mara;?></td>

</tr>

<tr>

<td colspan="3">English</td>

<td colspan="3"><?php echo $eng;?></td>

</tr>

<tr></tr>

<tr>

<td colspan="3">Total Marks</td>

<td colspan="3"><?php echo $tot;?></td>

</tr>

<tr>

<td colspan="3">Maximum Mark</td>

<td colspan="3"><?php echo $max;?></td>

</tr>

<tr>

<td colspan="3">Percentage</td>

<td colspan="3"><?php echo $perc;?></td>

</tr>

</table></center>

</form>

</body>

</html>

DEPARTMENT OF IT 68 III MCA LE 2016-18
WEB PROGRAMMING

OUTPUT:

DEPARTMENT OF IT 69 III MCA LE 2016-18
WEB PROGRAMMING

PROGRAM 10:

Program:

Write a PHP script to accept username and password.If in the first chance username and
password entered is correct,then display second form,otherwise display error message.

Code:

Msclog.php

<html>

<head>

</head>

<body>

<form id="form1" name ="form1" method="post" action="msclog1.php">

<p>&nbsp;</p>

<p>&nbsp;</p>

<table width="382" border="0" align="center">

<tr>

<td width="100">User Name</td>

<td width="177"><label>

<input type="text" name="user"/>

</label></td>

</tr>

<tr>

<td>password</td>

<td><label>

DEPARTMENT OF IT 70 III MCA LE 2016-18
WEB PROGRAMMING

<input type="password" name="pswd"/>

</label></td>

</tr>

<tr>

<td>&nbsp;</td>

<td><label>

<input type="submit" name="submit" value="submit"/>

</label></td>

</tr>

</table>

<p><&nbsp;</p>

</form>

</body>

</html>

Msclog1.php

<html>

<head>

</head>

<body>

</body>

</html>

<?php

$k=0;

$a=$_POST['user'];

$a=$_POST['pswd'];

DEPARTMENT OF IT 71 III MCA LE 2016-18
WEB PROGRAMMING

$con=mysql_connect("localhost","root");

if(!$con)

{

die('could not connect:'.mysql_error());

}

else

{

echo"coon";

}

mysql_select_db("login1" .$con);

$res=mysql_query("select * from log1");

while($row=mysql_fetch_array($res))

{

$user=$row[0];

$pswd=$row[1];

$count=$row[2];

}

if($user==$n and $$pswd==$b)

{

header("location:oper.php");

break;

}

else

{

$c=$count+1;

DEPARTMENT OF IT 72 III MCA LE 2016-18
WEB PROGRAMMING

echo $c;

}

if($count<3)

{

mysql_query("upadate log1 set count='$c' where user_name='$user' and password='$pswd'");

echo "try again";

}

else

{

echo "blocked";

mysql_query("upadate log1 set count=0 where user_name='$user' and password='$pswd'");

header("location:fff.php");

}

}

mysql_close($con);

?>

DEPARTMENT OF IT 73 III MCA LE 2016-18
WEB PROGRAMMING

DEPARTMENT OF IT 74 III MCA LE 2016-18