dongtou9934 2012-07-16 13:59
浏览 39
已采纳

无法从单选按钮获取价值

I want to get the data from radio button when I submit it, but I don't know why I can't get the value from radio it.

My code

<?php
   $choice = $_GET['choice'];
?>

<html>
<head>
</head>
<body>
    <form action="index.php" method="POST">
    <table align="center">
        <tr><td>Please select</td></tr>
        <tr><td><input type="radio" name="choice" value="0">aaaa</td></tr>
        <tr><td><input type="radio" name="choice" value="1">bbbb</td></tr>
        <tr><td><input type="radio" name="choice" value="2">cccc</td></tr>
        <tr><td><input type="radio" name="choice" value="3">dddd</td></tr>
        <tr><td><input type="submit" value="submit"></td></tr>
    </table>
             <?php echo"$choice";?>
    </form>
</body>
</html>
  • 写回答

5条回答 默认 最新

  • dongzhi2332 2012-07-16 14:02
    关注

    Use $_POST Instead of $_GET to get data from form. Or you can use $_REQUEST also.Replace $_GET['choice'] with $_POST['choice'] or $_REQUEST['choice'].

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?