PHP program to demonstrate switch control statements

PROGRAM

<?php
echo "
<form method='POST' action='' >
PLEASE SELECT WHICH CLASS OF TRAVEL YOU WISH <BR/>
<input type='radio' name='tclass' value='1'>FIRST CLASS <BR />
<input type='radio' name='tclass' value='2'>BUSINESS CLASS<br />
<input type='radio' name='tclass' value='3'>ECONOMY CLASS<br />
<input type='submit' value='submit' name='submit'>
</form>
";
if(isset($_POST['submit']))
{
$n = $_POST['tclass'];
switch($n)
{
case "1":
echo "you have selected FIRST CLASS";
break;
case "2":
echo "you have selected BUSINESS CLASS";
break;
case "3":
echo "you have selected ECONOMY CLASS";
break;

}



}
?>


OUTPUT


No comments:

Post a Comment