Mega Code Archive

 
Categories / Php / Form
 

Form radio buttons

<html>  <head>   <title>Your Favorites</title>  </head>          <body>                                     <form action="fav.php" method="post">                                                    <b>Please enter your first name:</b>               <input type="text" size="45" name="username">  <br>    <b>Please select your favorite color wine:</b> <br>                 <input type="radio" name="color" value="white">  White               <input type="radio" name="color" value="rosé">   Rosé    <input type="radio" name="color" value="red">    Red <br>    <b>Please enter your favorite dish:</b>               <input type="text" size="45" name="dish"><br><br>    <input type="submit" value="Submit This Form">  </form>              </body> </html> File: fav.php <html>  <head>   <title>Your submission</title>  </head>  <body>  <br>  <?php   $username = $_POST['username'];   $color =    $_POST['color'];   $dish =     $_POST['dish'];   if( $username != null )   {     echo( "Thanks for your selection $username <hr>" );   }   if( ( $color != null ) && ( $dish != null ) )   {     $msg = "You really enjoy $dish <br>";     $msg .= "- especially with a nice $color wine";     echo( $msg );   }  ?>  </body> </html>