龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

radiobutton php中获取表单单选框radiobutton数据的方法

时间:2014-06-06 15:14来源:网络整理 作者:网络 点击:
分享到:
php中获取表单单选框radiobutton数据的方法 html表单代码 [代码片段(19行)]

html表单代码

<html>
<body>                                  

<form action="mychoice.php" method="post">                                                
   <b>Enter Name:</b>           
   <input type="text" size="45" name="username">  <br>
   <b>Please select your favorite animal:</b> <br>             
   <input type="radio" name="animal" value="dog">Dog           
   <input type="radio" name="animal" value="cat">Cat
   <input type="radio" name="animal" value="fish">Fish <br>
   <input type="submit" value="Submit">
</form>            

</body>
</html>

                                后台php文件: mychoice.php;
<html>
 <head>
  <title>Form submission</title>
 </head>
 <body>
 <br>

 <?php
  $username = $_POST['username'];
  $animal =    $_POST['animal'];

  if(($animal != null))
  {
    $msg = "The animal you chose is $animal <br>";
    echo($msg);
  }
 ?>

 </body>
</html>

精彩图集

赞助商链接