You are on page 1of 73

GOVERNMENT

POLYTECHNIC COLLEGE
CHERTHALA

WEB PROGRAMMING
LABORATORY RECORD

Name .......................................................................

Class...........................................Roll No. ...............

Reg. No...............................Year......2022-23..........

DEPARTMENT OF
COMPUTER ENGINEERING

1
GOVERNMENT
POLYTECHNIC COLLEGE
CHERTHALA

LABORATORY RECORD

Name ………………………………………………
Class..................................... Roll No……………
Reg.No.......................................Year...................

Certificate
Certified that this is the bonafide record of work done
in......................................................................................................laboratory by
Sri................................................................................................................... during the
year.................2022-23..................

Internal Examiner Staff in Charge

External Examiner Head of Section

2
3
INDEX
EXP.NO: NAME PAGE NO:
1 SEARCH ENGINE 7-9
2 COLLEGE WEBSITE 10-14
3 LIST VIEW 15-18
4 BIODATA 19-22
5 PARAGRAPH 23-27
6 TABLE 28-31
7 REGISTRATION FORM 32-35
8 CALCULATOR 36-39
9 GRADE CALCULATION 40-44
10 FORM VALIDATION 45-51
11 PRODUCT OF TWO NUMBER 52-54

12 WISHING 55-57
13 FOREACH 57-59
14 EMPLOYEE LOGIN 60-62
15 EMPLOYEE PAY SLIP 63-67
16 DATABASE INSERTION 68-71

17 DISPLAY DETAILS FROM 72-75


DATABASE

4
5
EXP 1: DATE:29/9/22

SEARCH ENGINE
AIM: To familiarize various search engine

PROBLEM STATEMENT :

1. Search the same keywords in two different search


engines and compare their result.
2. Search the same image in two different search engines

Tools:

Web browser, image file, document file and an active internet


connection

Theory:

A web search engine is a software system that is designed to search


for information on the worldwide web. The search results are
generally prevented in a line of a result often referred to as search
engine results pages (SERPs). The information may be a mix of web
pages, images and other types of files. Some search engines also
mine data available in databases or open directories. Unlike web
directories, which are maintained only by human editors, search
engines also maintain real-time information by running on algorithm
on a web crawler.

6
• Web Crawler
Automated “spider” that follow-links and then analyses
content in pages to determine what should be indexed.
Metadata is very important in the phone.
• Indexing
Data about web pages are stored in an index
database for we in later queries. Some search engines
such as Google store all or part of the source page as
well as information about the web pages.
• Searching & Results
The engine looks up the index and provide a listing of
best matching web pages according to it’s criteria the
usefulness of a search engine depends on the relevance
of the result set it gives back

Procedure:

keywords in different search engines such as Google, Yahoo,


Bing, AOL, Wiki, bit Torrent and so on.

• The Plus operator (+) : Stop words are typically ignored by the
search engine. The plus operator tells search engine to include
those words in the result set.
• The tilde operator (~) : Include a tilde operator in front of a
word to return results that include synonyms.
• The wild card operator (*) : Google calls it the fill in the blank
operator for examples, amusement and any other terms the
Google search engine deems relevant.
• The OR operator (OR) or (I) : Use this operator to return result
with either of two terms.

7
• Numeric Ranges : You can refine searches that we numeric
terms by returning a specific range. But you must supply the
unit of measurement.
Eg :- MS Word 2010
• Related Sites : For example, related:www.youtube.com can be
used to find sites similar to YouTube.
• Related Sites : For example, related:www.youtube.com can be
used to find sites similar to YouTube
• Advanced Searches : Click the advanced search button by the
search box on the Google start or results page to refine your
search by date, country, amount, language or other criteria.

RESULT:
Studied about various search engines and various
methods for searching.

8
EXP 2: DATE:29/9/22

COLLEGE WEBSITE
AIM: Design an HTML page about your college, containing text in
the form of paragraph, give suitable heading, style and an image.
Show different names as links when user clicks on the links ,it should
open another web page about each department(show the details of
two department).

Program :

COLLEG WEBSITE.HTML

<html>
<head>
<title>GPTC CHERTHALA</title>
</head>
<body bgcolor="skyblue" align="center" >
<h1 align="center">GOVT.Polytechnic College Cherthala</h1>
<p><h3> Govt. Polytechnic College. Cherthala is the first professional
Engineer Institution of excellence under government Sector in
Alappuzha district of kerala state.Govt.Polytechnic College. Even
though the institution located in the heart of cherthala town , beside
the national highway, it is surrounded by several villages which are
backward. This institution serves as a nodal polytechnic for the other
polytechnic colleges in the Alappuzha District.This institution started
functioning as junior Technical high school in 1994 it was upgraded
into polytechnic college,Imparting three year of diploma course in
engineering/Technical under department of technical education,
Government of kerala later Govt. of kerala has sanctioned two more
diploma courses in Engineering technology </h3></p>
9
<img src="pclogo.jpeg"height="300"width="400">
<h3> DEPARTMENT</h3>
<a href="ct.html"> Computer Technology</a><br>
<a href="mech.html"> Mechanical</a><br>
</body>
</html>

CT.HTML

<html>
<body align="center" bgcolor="violet">
<title> CT </title>
<h1> COMPUTER TECHNOLOGY </h1>
<p>
The department of Computer Engineering was established in the
year 2017. With an annual intake of 63 student , department offers 3
year programme in Diploma in computer engineering . Being a new
programmer ,the department aims to provide quality education in
computer technology .
</p>
<img src="ctlab.jpeg" height="300" width="400">
<a href="collegewebsite.html"> Back to home </a>
</body>
</html>
MECH.HTML

<html>
<body align="center" bgcolor="pink">
<title> ME </title>
<h1> mechanical </h1>
<p>
Diploma in Mechanical Engineering is a 3 year polytechnic
course that can be pursued by students after class 10. Diploma in
Mechanical Engineering deals with design, manufacture and

10
maintenance of mechanical equipment by applying the basic
principles of mechanics.
</p>
<img src="mechanical.jpeg" height="300" width="400">
<a href="collegewebsite.html"> Back to home </a>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

11
Collegewebsite.html

ct.html

12
mech.html

13
EXP 3: DATE:29/9/22

LIST VIEW

AIM: Design an HTML page showing ordered list, unordered


list, definition list, & nested list using proper tags and
attributes.(show each list separately with suitable heading).

Program :

<html>
<head>
<style>
li {
font-size: 22px;
}
dl {
font-size: 18px;
}
h1 {
font-size: 33px;
color: #e92503;
}
</style>
</head>
<body bgcolor="#838788" style="padding-left: 550px">
<h1>LIST VIEW</h1>
<ol type="1">
<li style="color: blue">DRINGS</li>
<ul>

14
<li style="color: #dcf907">TEA</li>
<dl>
<dd>MILK TEA</dd>
<dd>BLACK TEA</dd>
<dd>BUBBLE TEA</dd>
<dd>LEMON TEA</dd>
</dl>
</ul>
<ul>
<li style="color: #dcf907">JUICE</li>
<dl>
<dd>ORANGR JUICE</dd>
<dd>GRAPE JUICE</dd>
<dd>PINEAPPLE JUICE</dd>
<dd>APPLE JUICE</dd>
</dl>
</ul>
<li style="color: blue">FOOD</li>
<ul>
<li style="color: #dcf907">INDIAN</li>
<dl>
<dd>BIRIYANI</dd>
<dd>SADHYA</dd>
</dl>
</ul>
<ul>
<li style="color: #dcf907">ITALIAN</li>
<dl>
<dd>PASTA</dd>
<dd>Ragu Alla Bolognese</dd>
</dl>
</ul>
<ul>

15
<li style="color: #dcf907">CHINES</li>
<dl>
<dd>CHICKEN NOODLES</dd>
<dd>Dumplings</dd>
<dd>Ma Po Tofu</dd>
</dl>
</ul>
</ol>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

16
17
EXP 4: DATE:19/10/22

BIODATA

AIM: Design a web page to show your biodata.Set suitable


background color to the page and set title as ‘Biodata’.Give
suitable heading.Apply font tags and its attributes.Use HTML
table to prepare biodata in the following format

Program :

<html>
<head>
<title>BIODATA</title>
</head>
<body bgcolor="aquamarine" >
<center>
<h1 style="text-align: center;
font-size: 60px;
padding-bottom:
30px;padding-top: 30px;
color: #0ca1f7;
background: white;">BIODATA </h1>
<div>
<p>Personal Details</p>
<table border="1px solid black" cellspacing="6px"
cellpadding="6px">
<tr>
<td style="font-weight: bold;">NAME</td>
<td >YADHUKRISHNAN S</td>

18
</tr>
<tr>
<td style="font-weight: bold;">ADDRESS</td>
<td>
<pre>PUTHENPARAMBIL, KAITHAVANA,
SANATHANAPURAM WARD, ALAPPUZHA,68803</pre>
</td>
</tr>
</table>
<p>EDUCATIONAL QUALIFICATION</p>
<table border="1px solid black" cellspacing="6px"
cellpadding="6px">
<tr>
<th>SI No</th>
<th>QUALIFICATION</th>
<th>NAME OF INSTITUTE</th>
<th>YEAR OF PASS</th>
<th>GRADE</th>
</tr>
<tr>
<td>1</td>
<td>Plus Two</td>
<td>HSS THIRUVAMPADY</td>
<td>2020</td>
<td>66%</td>
</tr>
<tr>
<td>2</td>
<td>SSLC</td>
<td>HSS THIRUVAMPADY</td>
<td>2018</td>
<td>86%</td>
</tr>

19
</table>
</body>
</html>
</html>
RESULT:
Program executed successfully and output obtained.

20
21
EXP 5: DATE:27/10/22

PARAGRAPH

AIM: Create and text an HTML document that has 5 paragraph of


text.Usedifferent styles all of the styles must be in a
document style sheet

Program :

Paragraph.html

<html>
<head>
<title>paragraphs</title>
<link rel="stylesheet" href="paragraph.css">
</head>
<body>
<center><h1>Paragraphs</h1></center>
<div class="content"><br>
<div class="p1">
<p>A good example of a paragraph contains a topic
sentence, details and a conclusion. 'There are many
different kinds of animals that live in China. Tigers and
leopards are animals that live in China's forests in the
north. In the jungles, monkeys swing in the trees and
elephants walk through the brush.</p>
</div><br>
<div class="p2">

22
<p>A good example of a paragraph contains a
topic sentence, details and a conclusion. 'There are many
different kinds of animals that live in China. Tigers and
leopards are animals that live in China's forests in the
north. In the jungles, monkeys swing in the trees and
elephants walk through the brush.</p>
</div><br>
<div class="p3">
<p>A good example of a paragraph contains a
topic sentence, details and a conclusion. 'There are many
different kinds of animals that live in China. Tigers and
leopards are animals that live in China's forests in the
north. In the jungles, monkeys swing in the trees and
elephants walk through the brush.</p>
</div><br>
<div class="p1">
<p>A good example of a paragraph contains a
topic sentence, details and a conclusion. 'There are many
different kinds of animals that live in China. Tigers and
leopards are animals that live in China's forests in the
north. In the jungles, monkeys swing in the trees and
elephants walk through the brush.</p>
</div><br>
<div class="p2">
<p>A good example of a paragraph contains a
topic sentence, details and a conclusion. 'There are many
different kinds of animals that live in China. Tigers and
leopards are animals that live in China's forests in the
north. In the jungles, monkeys swing in the trees and
elephants walk through the brush.</p>
</div><br>
<div class="p3">
<p>A good example of a paragraph contains a
topic sentence, details and a conclusion. 'There are many
23
different kinds of animals that live in China. Tigers and
leopards are animals that live in China's forests in the
north. In the jungles, monkeys swing in the trees and
elephants walk through the brush.</p>
</div><br>
</div>
</body>
</html>

Paragraph.css

.p1{
width: 94%;
height: 75px;
margin-left: 20px;
padding-left:20px;
border: 2px solid tomato;
background-color: pink;
color:blue;
}
.p2{
width: 94%;
height :75px;
margin-left:20px;
padding-left: 30px;
padding-right: 30px;
border:2px solid tomato;
background-color: black;
color:yellow;
}
.p3{
width:94%;
24
height: 75px;
margin-left:20px;
margin-right:20px;
padding-left: 20px;
padding-right: 20px;
text-indent:1cm;
background-color: green;
color:#fff;
border:2px solid black;
}
.content{
width:100%;
height: 600px;
background-color:slategray;
border:4px solid #fff;
}

RESULT:
Program executed successfully and output obtained.

25
26
EXP 6 : DATE:6/10/22

TABLE

AIM: Create the following table with dummy data.

Program :

<html>
<head>
<title>TRAIN_DETAILS</title>
<style>
table
{
border-collapse: collapse;
}
th
{
padding: 10px;
font-size: 20px;
background: white;
color: red;
}
td
{
27
padding: 10px;
}
h1
{
padding-top: 30px;
padding-bottom: 30px;
text-align: center;
font-size: 40px;
}
</style>
</head>
<body>
<h1>TRAIN DETAILS</h1>
<table border="8px solid black" align="center">
<tr>
<th rowspan=2>Name Of Train </th>
<th rowspan=2> Place</th>
<th rowspan=2> Destination</th>
<th rowspan=2> Train Number</th>
<th colspan=2><center>Time</center></th>
<th rowspan=2>Fare</th>
</tr>
<tr>
<th>Arrival</th>
<th>Departure</th>
</tr>
<tr>
<td>Dacken express</td>
<td>Mumbai_pune</td>
<td>300 km.</td>
<td>AS2233</td>
<td>3:00pm</td>
<td>7:00pm</td>

28
<td>50 Rs.</td>
</tr>
<tr>
<td>Chanaya express</td>
<td>Dadar_chanay</td>
<td>1500 km.</td>
<td>GS1241.</td>
<td>12:00pm</td>
<td>2:00pm</td>
<td>5000 Rs.</td>
</tr>
<tr>
<td>kamayani express</td>
<td>Varanasi_dadar</td>
<td>1500 km.</td>
<td>WY2364</td>
<td>12:00pm</td>
<td>2:00pm</td>
<td>5000 Rs.</td>
</tr>
</table>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

29
30
EXP 7: DATE:19/10/22

REGISTRATION FORM

AIM: Design a registration form using HTML.

Program :

<html>
<head>
<title>Registration Form</title>
<style>
th{
font-size: 30px;
color: red;
}
td{
font-size: 20px;
}
</style>
</head>
<body bgcolor="#20fa82">
<center>
<form name="contact" method="post">
<table cellpadding="10px" cellspacing="6px" align="top"
border=1 >
<tr>
<th align=center colspan=2>Registration Form</th>
</tr>
<tr>
<td> Name</td>
31
<td><input type="text" id="name" name="name"></td>
</tr>
<tr>
<td> Address</td>
<td><textarea rows="4" cols="30"></textarea></td>
</tr>
<tr>
<td> Sex</td>
<td><input type="radio" name="sex">Male<br>
<input type="radio" name="sex">Female</td>
</tr>
<tr>
<td> Date of Birth</td>
<td><input type="date"></td>
</tr>
<tr>
<td>Qualification</td>
<td><select name="Qualification">
<option value="sslc">SSLC</option>
<option value="plus2">PLUS 2</option>
<option value="diploma">Diploma</option>
</select>
</td>
</tr>
<tr>
<td>Experience</td>
<td><input type="checkbox" id="pri">Private<br>
<input type="checkbox" id="gov">Government<br>
<input type="checkbox" id="pub">Public<br>
<input type="checkbox" id="quasi">Quasi Govt.<br>
</td>
</tr>
<tr>

32
<td> E-Mail-ID</td>
<td><input type="email"></td>
</tr>
<tr>
<td> Mobile</td>
<td><input type="text"></td>
</tr>
<tr>
<td width=50% align=center><input type="button"
value="Submit"></td>
<td align=center><input type="reset"
value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

33
34
EXP 8: DATE:27/10/22

CALCULATOR

AIM: Write a Java Script program to implement simple


calculator.
Program :

<html>
<head>
<title>calculator </title>
</head>
<body bgcolor="yellow">
<center>
<form>
<table cellpadding="2px" cellspacing="6px" border=1
align="center">
<tr>
<td colspan="2"> <H1
ALIGN="CENTER">CALCULATOR</H1> </td>
</tr>
<tr>
<td>enter 1st no: </td>
<td><input type="text" id="num1"></td>
</tr>
<tr>
<td>enter 2nd no: </td>
<td><input type="text" id="num2"></td>
</tr>
<tr>
<td>answer:</td>

35
<td><input type="text" id="num3"></td>
</tr>
<tr>
<td><input type="button" value="+" style="width:
85px;height: 85px;" onclick="addnum()">
<input type="button" value="-" style="width:
85px;height: 85px;" onclick="sumnum()"></td>
<td> <input type="button" value="*" style="width:
85px;height: 85px;" onclick="mulnum()">
<input type="button" value="/" style="width:
85px;height: 85px;" onclick="divnum()"></td>
</tr>
<tr>
<td colspan="3" align="center"><input type="reset"
value="clear" style="width: 50px;height: 30px;"></td>
</tr>
</table>
</form>
<script>
function addnum()
{
var a=document.getElementById("num1");
var b=document.getElementById("num2");
var x=parseInt(a.value)+parseInt(b.value);
document.getElementById("num3").value=x;
}

function sumnum()
{
var a=document.getElementById("num1");
var b=document.getElementById("num2");
var x=parseInt(a.value)-parseInt(b.value);
document.getElementById("num3").value=x;

36
}

function mulnum()
{
var a=document.getElementById("num1");
var b=document.getElementById("num2");
var x=parseInt(a.value)*parseInt(b.value);
document.getElementById("num3").value=x;
}

function divnum()
{
var a=document.getElementById("num1");
var b=document.getElementById("num2");
var x=parseFloat(a.value)/parseFloat(b.value);
document.getElementById("num3").value=x;
}
</script>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

37
EXP 9: DATE:10/11/22
38
GRADE CALCULATION

AIM: Write suitable script to read data from the following form and
declare the result given in the form along with the total mark and
grade.

Program :

<html>
<head>
<title>data sheet</title>
<script>
function calculate(){
var regno=document.markval.regno.value;
if(regno.trim()==""){
alert("Enter Reg no:");
document.markval.mark1.focus();
return;
}

var mark1=document.markval.mark1.value;
if(mark1.trim()==""){
alert("Enter mark 1");
document.markval.mark1.focus();
return;
}

if(mark1<0 || mark1>100){
alert("Enter a value > 0 & value <= 100")

39
document.markval.mark1.focus();
return;
}

var mark2=document.markval.mark2.value;
if(mark2.trim()==""){
alert("Enter mark 2");
document.markval.mark2.focus();
return;
}

if(mark2<0 || mark2>100){
alert("Enter a value > 0 & value <= 100")
document.markval.mark2.focus();
return;
}

var tot=parseInt(mark1)+parseInt(mark2);
document.getElementById("total").value=tot;

if(tot<70){

document.getElementById("result").value="fail";
}else{

document.getElementById("result").value="pass";
}
if(tot>180){

document.getElementById("grade").value="S";
}else if(tot>150){

document.getElementById("grade").value="a";

40
}else if(tot>130){

document.getElementById("grade").value="b";
}else if(tot>110){
document.getElementById("grade").value="c";
}else if(tot>90){

document.getElementById("grade").value="d";
}else if(tot>70){

document.getElementById("grade").value="e";
}else{
document.getElementById("grade").value="f";
}

}
</script>
</head>
<body bgcolor="YELLOW">
<center>
<h1>DATA SHEET</h1>
<h3>Please enter mark out of 100</h3>
<form name="markval" method="get">
<table colspan="2" cellpadding = "8px" cellspacing="8px"
align = "top" border = "3">
<tr>
<td>Reg No:</td>
<td><input type="text" name="regno"></td
</tr>
<tr>
<td>Mark 1:</td>
<td><input type="text" name="mark1"></td></td>
</tr>

41
<tr>
<td>Mark 2: </td>
<td><input type="text" name="mark2"></td>
</tr>
<tr>
<td align="center" ><input type="button"
value="submit" onclick="calculate()"></td>
<td align="center" ><input type="reset"
value="RESET" ></td>
</tr>
<tr>
<td>Total: </td>
<td><input type="text" id="total"></td>
</tr>
<tr>
<td>Result: </td>
<td><input type="text" id="result"></td>
</tr>
<tr>
<td>Grade: </td>
<td><input type="text" id="grade"></td>
</tr>
</table>
</form>
</center>

</body>
</html>
RESULT:
Program executed successfully and output obtained.

42
43
EXP 10: DATE:03/11/22

FORM VALIDATION

AIM: Design a form to collect employee details using html fields


name, employee code, basic salary, designation, gender, address,
qualification, email-id implement form validation.
a) Fields are mandatory
b) Email must be in valid format
c) Basic salary must be numeric

Program :

<html>
<head>
<title>validation</title>
<script>
function validation(){
var ecode=document.contact.ecode.value;
if(ecode.trim()==""){
alert("Enter employee code");
document.contact.ecode.focus();
return false;
}

var ename=document.contact.ename.value;
if(ename.trim()==""){
alert("enter employee name");
document.contact.ename.focus();
44
return false;
}

var bsalary=document.contact.bsalary.value;
if(bsalary.trim()==""){
alert("enter basic salary");
document.contact.bsalary.focus();
return false;
}

var address=document.contact.address.value;
if(address.trim()==""){
alert("enter employee address");
document.contact.address.focus();
return false;
}

var sex=document.contact.sex.value;
if(sex==""){
alert("enter gender");
return false;
}

var phno=document.contact.phno.value;
if(phno.trim()==""){
alert("enter phone number");
document.contact.phno.focus();
return false;
}

var email=document.contact.email.value;
if(email.trim()==""){
alert("enter e-mail");

45
document.contact.email.focus();
return false;
}
if(email.indexOf("@",0)<0){
alert("enter valid e-mail WITH @ ");
document.contact.email.focus();
return false;
}
if(email.indexOf(".",0)<0){
alert("enter valid e-mail WITH .");
document.contact.email.focus();
return false;
}

var chk=false;
var quali=document.contact.quali;
for(var i=0;i<quali.length;i++){
if(quali[i].checked)
chk=true;
}
if(chk==false){
alert("enter qualification");
return false;
}
return true;

}
</script>
</head>
<body bgcolor="aquamarine">
<center>
<b><h1><font colour =
"blue">Employeform</font></h1></b></br>

46
<form name="contact" onsubmit="return
validation()">
<table cellpadding = "8px" cellspacing="8px" align = "top"
border = "3" >
<tr >
<th colspan="2" ></th>
</tr>
<tr >
<th align = center >Salary form </th>
</tr>
<tr>
<td>Employee code</td>
<td><input type = "text" id = "ecode"> </td>
</tr>
<tr>
<td>Employee name</td>
<td><input type = "text" name = "ename"> </td>
</tr>
<tr>
<td>Basic salary</td>
<td><input type = "text" name = "bsalary">
</td>
</tr>
<tr>
<td>Gender</td>
<td>
<input type="radio" name="sex">male<br>
<input type="radio" name="sex">female

</td>
</tr>
<tr>

47
<td>Qualification</td>
<td><input type="checkbox" name = "quali">sslc<br>
<input type="checkbox" name = "quali">+2<br>
<input type="checkbox" name = "quali">degree<br>
<input type="checkbox" name= "quali">diploma<br>
</td>

</tr>
<tr>
<td>Email-id</td>
<td><input type ="text" name="email"></td>

</tr>
<tr>
<td>Ph no:</td>
<td><input type ="text" name="phno"></td>

</tr>
<tr>
<td>Address</td>
<td><textarea row = "4" cols = "30"
name="address"></textarea>
</td>
</tr>
<tr>
<td width = 50% align = "center"><input type = "submit"
value = "submit"></td>
<td align="center"><input type="reset"
value="Reset"></td>
</tr>
</table>
</form>
</body>

48
</html>

RESULT:
Program executed successfully and output obtained.

49
50
EXP 11: DATE:10/11/22

PRODUCT OF TWO NUMBER

AIM:HTML page to find the product of 2 number in javascript using


onclick event.

Program :

<html>
<head>
<title>PRODUCT</title>
<script>
function getproduct(){
var num1=document.mul.num1.value;
var num2=document.mul.num2.value;
var x=num1*num2;
document.mul.product.value=x;

}
</script>
</head>
<body bgcolor="cyan">
<center>
<form name="mul">
<table cellpadding = "10px" cellspacing="10px" align =
"top" border = "3">
<tr>
<th>First no: <input type="text"
name="num1"></th><br>
51
</tr>
<tr>
<th>second no: <input type="text"
name="num2"></th><br>
</tr>
<tr>
<th>product: <input type="text"
name="product"></th>
</tr>
<tr>
<th><center><input type="button" value="PRODUCT"
onclick="getproduct()"></center></th>
</tr>
</table>
</form>

</center>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

52
53
EXP 12: DATE:10/11/22

WISHING

AIM: Write a PHP script to display formatted system date, time


& wish the user based on time.

Program :

<html>
<body>

<?php
$hour =date('h');
echo "$hour"."<br>";
if ($hour<12){
echo "GOOD MORNING!";
}
else if($hour==12 && $hour<16){
echo "GOOD AFTERNOON!";
}
else{
echo "GOOD EVENING!";
}
?>

</body>
</html>

RESULT:
Program executed successfully and output obtained.
54
EXP 13: DATE:17/11/22
55
FOREACH

AIM: To create an associative array and display it using for


foreach loop.

Program :

foreach.php

<html>
<body bgcolor="yellow">
<h2 align="center">MAJOR WEBSITES</h2>

<?php
$web =array("vpk"=>"www.vpk.com","google"=>"www.google.c
om","yahoo"=>"www.yahoo.com");
echo "<table border=2 align=center>";
echo "<tr>";
echo "<th>NAME OF SITES</th>";
echo "<th>ADDRESS OF SITES</th>";
echo"</tr>";

foreach($web as $x => $w) {


echo "<tr>";
echo "<td>",$x,"</td>";
echo "<td>",$w,"</td>";
echo" </tr>";
}

56
echo "</table>";
?>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

57
EXP 14: DATE:17/11/22
58
EMPLOYEE LOGIN

AIM: Design a form to Login user information and check its


validity using PHP script, If it is invalid display the form again.

Program :

Login.html

<html>
<head>
<title>LOGIN PAGE</title>
</head>
<body bgcolor="aquamarine">
<form action="login.php" method="POST" name="lg">
<center>
<table cellspacing="7px" cellpadding="2px" border="1" >
<tr>
<th>username:</th>
<th><input type="text" name="uname"></th>
</tr>
<tr>
<th>password:</th>
<th><input type="password" name="pwd"></th>
</tr>
</table>
<table>
<br>
<tr>

59
<th allign="center"><input type="submit" value="LOGIN"
style="height: 30px; width: 75px; "></th>
<th allign="center"><input type="reset" value="RESET"
style="height: 30px; width: 75px; "></th>
</tr>
</table>
</form>
</body>
</html>

Login.php

<?php
$un=$_POST["uname"];
$pw=$_POST["pwd"];

$user="yadhu";
$pass="yadhu";
if($user==$un && $pass==$pw)
{
echo"WELCOME :".$un;
echo"<br> LOGIN SUCCESFULL";
}
else
{
header("location:login.html");
}
?>

RESULT:
Program executed successfully and output obtained.
Login.html

60
Login.php

EXP 15: DATE:17/11/22

61
EMPLOYEE PAY SLIP

AIM: Prepare pay slip for employees of an organization by


applying the following criteria using PHP:

Gross pay = Basic pay + DA + HRA


Net pay = Gross pay – Deductions
Deductions are Loan, PF & Insurance.
Design HTML form with suitable controls

Program :

EMPLOYEE.HTML

<html>
<head>
<title>Employee salary</title>

</head>
<body bgcolor="#00fbff">
<center>
62
<form name = "employee" method = "post" action = "emp.php">
<table cellspacing="6px" cellpadding ="2px" border="2" >
<tr>
<th colspan="2"><h1>EMPLOYEE SLIP</h1></th>
</tr>
<tr>
<th>Employee_code:</th>
<th><input type="text" name = "ecode"></th>
</tr>
<tr>
<th>Employee_name:</th>
<th><input type="text" name = "ename"></th>
</tr>
<tr>
<th>Basic_pay:</th>
<th><input type="text" name = "ba"></th>
</tr>
<tr>
<th>Dedcution:</th>
<th><input type="text" name = "ded"></th>
</tr>
<tr>
<th><input type="submit" value = "SUBMIT"></th>
<th><input type="reset" value="RESET"></th>
</tr>
</form>
</table>
</body>
</html>

EMPLOYEE.PHP

63
<html>
<body>
<?php
$ecode=$_POST["ecode"];
$ename=$_POST['ename'];
$ba=$_POST['ba'];
$deduction=$_POST['ded'];
if($ba<=20000){
$da=($ba*38)/100;
$hra=500;
$gp=$ba+$hra+$da;
$netp=$gp-$deduction;
}else if($ba>=20001 && $ba<=30000){
$da=($ba*30)/100;
$hra=250;
$gp=$ba+$hra+$da;
$netp=$gp-$deduction;
}else{
$da=($ba*25)/100;
$hra=150;
$gp=$ba+$hra+$da;
$netp=$gp-$deduction;
}
echo "employee code ".$ecode."<br>";
echo "employee name ".$ename."<br>";
echo "basic pay ".$ba."<br>";
echo "DA ".$da."<br>";
echo "HRA ".$hra."<br>";
echo "GP ".$gp."<br>";
echo "NETPAY ".$netp."<br>";
?>
</body>
</html>

64
RESULT:
Program executed successfully and output obtained.

EMPLOYEE.HTML

65
EMPLOYEE.PHP

EXP 16: DATE:24/11/22

66
DATABASE INSERTION

AIM: Write a PHP script to insert values through a form to the


table CT that is under the database student. Design the form as

Mark Details
Register_Number
Name
Department
Mark1
Mark2
Mark3
Submit

Program :

CLASSROOM.HTML

<html>
<head>
<title>classroom</title>
</head>
<body bgcolor="#ed06ce">
<center>
<form name="classroom" method="post"
action="classroom.php">
<table border="2" cellspacing="7px">
<tr>
<td>REG NO: </td>
67
<td><input type="text" name="regno"></td>
</tr>
<tr>
<td>NAME: </td>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td>DEPARTMENT:</td>
<td><input type="text" name="dept"></td>
</tr>
<tr>
<td>MARK1:</td>
<td><input type="text" name="m1"></td>
</tr>
<tr>
<td>MARK2:</td>
<td><input type="text" name="m2"></td>
</tr>
<tr>
<td>MARK3:</td>
<td><input type="text" name="m3"></td>
</tr>
<tr>
<td align="center" ><input type="reset"
value="RESET"></td>
<td align="center" ><input type="submit"
value="SUBMIT"></td>
</tr>
</table>

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

68
CLASSROOM.PHP

<?php
$regno=$_POST["regno"];
$name=$_POST["name"];
$dept=$_POST["dept"];
$m1=$_POST["m1"];
$m2=$_POST["m2"];
$m3=$_POST["m3"];
$con=mysqli_connect("localhost","root","root","studentnew”);

if(!$con)
echo "db connect error"."<br>";
else
echo"db connected";
$sql="insert into student(regno,name,dept,m1,m2,m3)
values ('$regno','$name','$dept','$m1','$m2','$m3')";
$res=mysqli_query($con,$sql);
if($res)
echo "data inserted succesfully"."<br>";
else
echo "insertion error"."<br>";
?>

RESULT:
Program executed successfully and output obtained.
CLASSROOM.HTML

69
EXP 17: DATE:29/11/22

70
DISPLAY DETAILS FROM
DATABASE

AIM: display all the details in the ct table of student database in


a neat table format.

Program :

retrive.PHP

<html>
<body>
<?php
$con=mysqli_connect("localhost","root","root","studentnew");
if(!$con)
echo"DB CONNECTION ERROR!"."<br>";
else
echo"DB CONNECTED SUCCEFULLY..."."<br>";

$sql="select * from student";


$res=mysqli_query($con,$sql);

echo"<center>";
echo"<h1>STUDENT DETAILS</h1>";

echo"<table border='2'>";
echo"<tr>";
echo"<th>REG NO</th>";
71
echo"<th>NAME</th>";
echo"<th>DEPTARTMENT</th>";
echo"<th>MARK 1</th>";
echo"<th>MARK 2</th>";
echo"<th>MARK 2</th>";
while($row=mysqli_fetch_array($res))
{
echo"<tr>";
echo"<td>".$row['regno']."</td>";
echo"<td>".$row['name']."</td>";
echo"<td>".$row['dept']."</td>";
echo"<td>".$row['m1']."</td>";
echo"<td>".$row['m2']."</td>";
echo"<td>".$row['m3']."</td>";
echo"</tr>";
}
echo"</table>";
?>
</body>
</html>

RESULT:
Program executed successfully and output obtained.

72
retrive.PHP

73

You might also like