radiobutton php中获取表单单选框radiobutton数据的方法
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>
精彩图集
精彩文章






