All Practicals On 5th Chapter
All Practicals On 5th Chapter
**********************************************************************
Program:- Vote.php
<?php
if(isset($_POST['submit']))
{
$age=$_POST['age'];
if($age>=18)
echo"<br><h1>Congratulation,You are Eligible for Vote....<h1>";
else
echo"<br><h1>You are not Eligible for Vote....</h1>";
}
?>
Output 1:- Vote.html
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.
Program:- Vowels.html
<html>
<body>
<h2>String Functions</h2>
<form method="post"action="Vowels.php">
Enter string <input type="text" name="t1"><br><br>
<input type="submit" name="submit" value="count vowels">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$str=strtolower($_POST['t1']);
$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 are :$num";
}
?>
Practical No:14 Name Of Student:
SOP 6 : Write a program using PHP to calculate Electricity bill by accepting the
limits.
Forfirst100 units-Rs. 4
Fornext100 units-Rs. 5
Fornextallunits-Rs.6
Program:- Bill.html
<html>
<body>
<h2> Electricity Bill </h2>
<form method="post" action="bill.php"> Enter number of units:
<input type="text" name="units"><br><br>
<input type="submit" name="submit" value="Calculate Bill">
</form>
</body>
</html>
Program:- Bill.php
<?php
if(isset($_POST['submit']))
{
$units=($_POST['units']);
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";
}
}
}
?>
Output:- Bill.html