php 获取表单单选框radiobutton数据的简单示例

前端之家收集整理的这篇文章主要介绍了php 获取表单单选框radiobutton数据的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP获取表单单选框radiobutton数据的方法感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
html表单代码

/**
 * PHP获取表单单选框radiobutton数据的方法
 *
 * @param 
 * @arrange 512-笔记网: www.512Pic.com
 **/
<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>
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
后台PHP文件
mychoice.PHP

/**
 * PHP获取表单单选框radiobutton数据的方法
 *
 * @param 
 * @arrange 512-笔记网: www.512Pic.com
 **/
<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>
/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528555.html

猜你在找的PHP相关文章