How to select gender in PHP?| EasyCoding45

 In This Tutorial we are going to learn how we can write a PHP program to select a gender.

Note:-

            I have used Switch case in PHP file.

Program :-(save it as gender.HTML)

<html>

<head>

<form method=post action="gender.php">

Select gender :<br>

<input type=radio name=r1 value=1>Male<br>

<input type=radio name=r1 value=2>female<br>

<input type=submit value=select>

</form>

</head>

</html>


Program :-(save it as gender.php)

<?php


$opt=$_POST['r1'];


switch($opt)

{

case 1:

echo "<h3>You selected Male</h3>";

break;

case 2:

echo "<h3>You Selected Female</h3>";

break;


}


?>


Output :--
                


Comments