34. PHP Program to Determine Whether A Company Insured Driver or Not.
How does this program work?
- In this program you are going to learn about how to Check Status for given problem based on Conditons using PHP.
- In this program we can solve the given problem by using nested-if condition.
Here is the code
1. If the driver is married
2. If the driver is unmarried, male and above 30 years of age
3. If the driver is unmarried, female and above 25 years of age
In all other cases, the driver is not insured.
If the marital status, sex, age of the driver are the inputs.
write a program to determine whether the driver is insured or not. (use ‘nested-if’).
<html>
<head>
<title>PHP Program To Check the Status for the given Problem</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="gender" value="" placeholder="Enter gender (M/m or F/f):"/> </td>
</tr>
<tr>
<td> <input type="text" name="status" value="" placeholder="Enter marital status"/> </td>
</tr>
<tr>
<td> <input type="text" name="age" value="" placeholder="Enter your age"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$gender = $_POST['gender'];
$status = $_POST['status'];
$age = $_POST['age'];
if($status == "married")
{
echo " Driver is insured " ;
}
else
if($gender == "male" && $age>30 && $status == "unmarried")
{
echo " Driver is insured ";
}
else
if($gender == "female" && $age>25 && $status == "unmarried")
{
echo " Driver is insured";
}
else
echo"Driver is not insured";
return 0;
}
?>
</body>
</html>