PHP
PRACTICAL NO :12 (SOP1)
AIM: PHP CODE TO CHECK IF A PERSON IS ELIGIBLE TO VOTE OR NOT
Filename: [Link]
<html>
<head>
<title>sop1</title>
</head>
<body>
<h1 align="center">Person Eligible to vote or not</h1>
<form name="f1" method="post" action="[Link]">
Enter your age<input type="text" name="t1">
<br>
<br>
<input type="submit" name="b1" value="check eligible">
</form>
</body>
</html>
File name :[Link]
<?php
if(isset($_POST['b1']))
{
$age=$_POST['t1'];
if($age>=18)
echo" you are eligible to vote"
else
echo "you are not eligible to vote"
}
?>
PRACTICAL NO : 13 (SOP6)
AIM: PHP CODE TO CALCULATE ELECTRICITY BILL BY ACCEPTING THE LIMITS
Filename: [Link]
<html>
<head>
<title>sop6</title>
</head>
<body>
<h1 align="center">Electricity bill</h1>
<form name="f1" method="post" action="[Link]">
Enter number of limits
<input typ="text" name="t1">
<br><br>
<input type="submit" name="b1" value="calculate bill">
</form>
</body>
</body>
</html>
[Link]
<?php
if(isset($_POST['b1']))
{
$units=($_POST['t1']);
if($units<=100)
{
$b=$units*4;
echo"your bill amount is :$b";
}
else
{
if($units<=200)
{
$b=400+($units-100)*5;
echo"your bill amount is :$b";
}
else
{
$b=400+500+($units-200)*6;
echo"your bill amount is : $b";
}
}
}
?>
PRACTICAL NO : 14(SOP4)
AIM: PHP CODE TO SAVE MARKS IN AN ARRAY AND DISPLAY MARKS,TOTAL AND PERCENTAGE.
Filename: [Link]
<?php
$m=array('english'=>56,
'hindi'=>76,
'marathi'=>56,
'maths'=>68,
'IT'=>69);
$total=$m['english']+$m['hindi']+$m['marathi']+$m['maths']+$m['IT'];
$percentage=$total/5;
echo"Marks in english :".$m['english'];
echo"<br>Marks in hindi :".$m['hindi'];
echo"<br>Marks in marathi :".$m['marathi'];
echo"<br>Marks in maths :".$m['maths'];
echo"<br>Marks in IT :".$m['IT'];
echo"<br>total :".$total;
echo"<br>percentage:".$percentage;
?>
OUTPUT
PRACTICAL NO: 12
PRACTICAL NO : 13
Practical no 14: