0% found this document useful (0 votes)
10 views6 pages

PHP_finalpracts

The document contains PHP code examples for three practical applications: checking voter eligibility based on age, calculating an electricity bill based on usage, and saving and displaying student marks along with total and percentage. Each practical includes HTML forms for user input and corresponding PHP scripts to process the input and display results. The examples demonstrate basic PHP functionalities such as form handling, conditional statements, and array usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views6 pages

PHP_finalpracts

The document contains PHP code examples for three practical applications: checking voter eligibility based on age, calculating an electricity bill based on usage, and saving and displaying student marks along with total and percentage. Each practical includes HTML forms for user input and corresponding PHP scripts to process the input and display results. The examples demonstrate basic PHP functionalities such as form handling, conditional statements, and array usage.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

PHP

PRACTICAL NO :12 (SOP1)


AIM: PHP CODE TO CHECK IF A PERSON IS ELIGIBLE TO VOTE OR NOT

Filename: age.html
<html>
<head>
<title>sop1</title>
</head>
<body>
<h1 align="center">Person Eligible to vote or not</h1>
<form name="f1" method="post" action="age.php">
Enter your age<input type="text" name="t1">
<br>
<br>
<input type="submit" name="b1" value="check eligible">
</form>
</body>
</html>

File name :age.php

<?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: bill.html
<html>
<head>
<title>sop6</title>
</head>
<body>
<h1 align="center">Electricity bill</h1>
<form name="f1" method="post" action="bill.php">
Enter number of limits
<input typ="text" name="t1">
<br><br>
<input type="submit" name="b1" value="calculate bill">
</form>
</body>
</body>
</html>

Bill.php
<?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: marks.php

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

You might also like