SOP1
Write A PHP PROGRAM to check if A person is eligible to vote or not.
The PROGRAM should include the following-
Minimum AGE required for vote is 18.
Use PHP functions.
Use Decision MAKING STATEMENT.
[Link]
<html>
<head>
<title>PHP PRACTICAL SOP1</title>
</head>
<body>
<h1 align="center">PERSON ELIGIBLE TO VOTE OR NOT
</h1>
<form method ="post" action= "[Link]">
Enter your age;
<input type="text" name="age"> <br><br>
<input type="submit" name="submit" value="check Eligible">
</form>
</body>
</html>
[Link]
<?php
if(isset($_POST['submit']))
{
$age=$_POST['age'];
if($age>=18)
echo"<br><br> You Are Eligible to vote";
else
echo"<br><br> You Are not Eligible to vote";
}
?>
SOP 2
Write A PHP function to count the TOTAL number of vowels (A,E,I,O,U)
from the string. Accept A STRING by using HTML form.
[Link]
<?php
if(isset($_POST['submit']))
{
$str=strtolower($_POST['str']);
$vowels=array('a','e','i','o','u');
$len=strlen($str);
$num=0;
for($i=0;$i<$len;$i++)
{
if(in_array($str[$i],$vowels))
{
$num++;
}
}
echo "Number of vowels :$num";
}
?>
[Link]
<html>
<head>
<title>PHP PRACTICAL SOP1</title>
</head>
<body>
<h1 align="center">Vowels in String </h1>
<form method="post" action="[Link]">
Enter String :
<input type="text" name="str"><br><br>
<input type="submit" name="submit" value="Count Vowels">
</form>
</body>
</html>
SOP 6
Write A PROGRAM using PHP to CALCULATE Electricity bill by ACCEPTING the limits.
For first 100 units - Rs. 4
For next 100 units - Rs. 5
For next ALL units - Rs. 6
[Link]
<?php
if(isset($_POST['submit']))
{
$nu=($_POST['TXT1']);
if ($nu<=100)
{
$eb=$nu*4;
echo "<br><br>electric bill amount is....".$eb;
}
if($nu>100 && $nu<=200)
{
$eb=$nu*5;
echo "<br><br>electric bill amount is....".$eb;
}
if($nu>200)
{
$eb=$nu*6;
echo "<br><br>electric bill amount is.... ".$eb;
}
}
?>
[Link]
<!doctype html>
<html>
<head> <title> electric bill </title>
</head>
<body bgcolor="yellow" text="red">
<h1 > electric bill </h1>
<form method="post" action="[Link]"><br><br>
Enter number of units: <input type="text" name="TXT1" > <br><br>
<br><br><input type="submit" name="submit" value="calculate
electric bill">
</form>
</body>
</html>