Server-Side Scripting (PHP)
SOP 1 : 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.
Html codevote.html<!DOCTYPE html> <head> <title>voter validation</title> </head> <body> <form action="vote.php" method="post"> enter age<input type="text" name="age" value=""> <input type="submit" name="submit" value="press here"> </form> </body></html>
PHP codevote.php<?phpif(isset($_POST['submit'])){$age=$_POST['age'];if($age>=18)echo "you are eligible for voting";elseecho "you are not eligible for voting";}?>
<!DOCTYPE html>
<head>
<title>voter validation</title>
</head>
<body>
<form action="vote.php" method="post">
enter age<input type="text" name="age" value="">
<input type="submit" name="submit" value="press here">
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$age=$_POST['age'];
if($age>=18)
echo "you are eligible for voting";
else
echo "you are not eligible for voting";
}
?>
0 Comments