It Practicals Remaining
It Practicals Remaining
AIM:
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.
CODE :
Vote.html
<html>
<head>
<title>Eligible to Vote or not</title>
</head>
<body>
<form action="age.php" method="post">
Enter Your Age :
<input type="text" name="t1" placeholder="Enter a
number">
<br><input type="submit" name="submit"
value="submit">
</form>
</body>
</html>
Age.php
<?php
if (isset($_POST['submit']))
{
$t1 = $_POST['t1'];
if($t1>=18)
{
echo "You are Eligible for Vote";
}
else
{
echo "You are not Eligible for Vote";
}
}
?>
OUTPUT:
Practical no : 12
AIM:
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.
CODE:
Vowel.html
<html>
<head>
<title>Total no of vowels</title>
</head>
<body>
<h1 align="center">String Function</h1>
<form action="vowel.php" method="post">
Enter The String :
<input type="text" name="t1" placeholder="Enter a string">
<br><input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Vowel.php
<?php
if (isset($_POST['submit']))
{
$t1 = strtolower($_POST['t1']);
$vowels = array('a','e','i','o','u');
$len = strlen($t1);
$num = 0;
for($i=0; $i<$len; $i++)
{
if(in_array($t1[$i], $vowels))
{
$num++;
}
}
echo "Number of vowels : ".$num;
}
?>
OUTPUT:
Practical no : 13
AIM:
Write a PHP program to save marks of English, Hindi, Marathi, Maths and
Information Technology in an array. Display marks of individual
subject along with total marks and percentage.
CODE:
Marks.php
<?php
$marks=array(78,63,74,84,96);
echo"<br><br>Marks scored in subject English is $marks[0]"."<br><br>Marks
scored in subject Hindi is $marks[1]"."<br><br>Marks scored in subject
Marathi is $marks[2]"."<br><br>Marks scored in subject Mathematics is
$marks[3]"."<br><br>Marks scored in subject Information Technology is
$marks[4]";
$t=0;
$x=0;
$c=count($marks);
for($x=0;$x<$c;$x++)
{
$t=$t+$marks[$x];
}
echo"<br><br>Total is $t";
$p=$t*100/500;
echo"<br><br>Percentage is $p";
?>
OUTPUT: