Demo.html
<html>
<title> Employee Information</title>
<body>
<h1
style="color:Orange;text-align:Center";> Checkbox, Radio Button
and Drop down</h1>
<form method="POST"
action="checkb1.php">
<fieldset>
Firstname:<input type="text"
name="fname"><br>
Lastname :<input type="text"
name="lname"><br>
Address :<textarea
rows="3" cols="40" name="add"
></textarea><br>
Phone:<input type="number"
name="phone" ><br>
Salary : <input type="number"
name="salary"><br>
</fieldset>
<fieldset>
Hobbies:</br>
<input type="checkbox" name="check_list[]"
value="Dancing">Dancing<br>
<input type="checkbox"
name="check_list[]" value="Singing">Singing<br>
<input type="checkbox"
name="check_list[]" value="Swimming">Swimming<br>
<input type="checkbox"
name="check_list[]" value="Studying">Studying<br>
</fieldset>
<fieldset>
Gender:
<input type="radio" name="gender"
value="Male">Male
<input type="radio" name="gender"
value="Female">Female<br>
</fieldset>
<fieldset>
Qualification : <select
name="Qualification">
<option value="underGraduate">UnderGraduate</option>
<option
value="Graduate">Graduate</option></option>
<option
value="PostGraduate">PostGraduate</option>
</select><br>
</fieldset>
<br>
<input type="Submit" name="Submit"
value="Check"/>
</form>
</body>
</html>
checkb1.php
<?php
//variable Declaration
$f=$_POST['fname'];
$l=$_POST['lname'];
$sal=$_POST['salary'];
$addr=$_POST['add'];
$ph=$_POST['phone'];
$gen=$_POST['gender'];
$qua=$_POST['Qualification'];
$n=0;
if(isset($_POST['Submit']))
{
echo"Employee
Information<br><br>";
echo"Name
: $f $l<br><br> Address : $addr<br><br> Phone :
$ph<br><br>";
echo"Salary
is : $sal<br>";
if($sal>=50000)
{
$n=1;
}
else
if($sal>=40000)
{
$n=2;
}
else
if($sal<=10000)
{
$n=3;
}
else
{
$n=0;
}
switch($n)
{
case
1:
echo"Excellent
Salary<br><br>";
break;
case
2:
echo"Very
Good Salary<br><br>";
break;
case
3:
echo"Please
increase your
Salary<br><br>";
break;
default
:
echo"enter
Correct salary<br><br>";
}
echo"Hobbies<br>";
if(!empty($_POST['check_list']))//
Check boxes
{
$checked=count($_POST['check_list']);
//check how many options selected
if($checked==4)
{
echo"WOW!
You are an all rounder!<br>";//if all check boxes selected
}
else
{
echo"You
have selected $checked items<br><br>"; //display which check
boxes selected
}
foreach($_POST['check_list']
as $sel)
{
echo"$sel<br>";
}
}
else
{
echo"<i>
Please select at least one value </i>";
}
echo"<br>Gender : ";
if($gen=="Male")
{
echo"Male<br>";
}
else
{
echo"Female<br>";
}
echo"<br>Qualification
: $qua";
}
?>
Output:
Result:
Employee Information
Name : suryosnata behera
Address : PUNE
Phone : 7890678909
Salary is : 40000
Very Good Salary
Hobbies
You have selected 3 items
Dancing
Singing
Swimming
Gender : Female
Qualification : Graduate
Name : suryosnata behera
Address : PUNE
Phone : 7890678909
Salary is : 40000
Very Good Salary
Hobbies
You have selected 3 items
Dancing
Singing
Swimming
Gender : Female
Qualification : Graduate
No comments:
Post a Comment