dssqq64884
2017-01-27 07:47
浏览 91
已采纳

表单提交后,PHP ::单选按钮值始终设置为“打开”

Here is my form:

<form method="post" enctype="multipart/form-data">
<input type="radio" name="sex" value="male" checked />
<input type="radio" name="sex" value"female"/>
<input type="submit" name="btn">
</form>

$_POST['sex'] = always I see the below output for the radio button:

See = string 'on'

It always gives "on" instead of male or female. This is what I have put in the form.

Am I doing something wrong here?

Please help.

If I use SELECT box, then it works well. But I need to make it work using radio button.

图片转代码服务由CSDN问答提供 功能建议

这是我的表格:

 &lt; form method =  “post”enctype =“multipart / form-data”&gt; 
&lt; input type =“radio”name =“sex”value =“male”checked /&gt; 
&lt; input type =“radio”name =“sex  “value”female“/&gt; 
&lt; input type =”submit“name =”btn“&gt; 
&lt; / form&gt; 
   
 
 

$ _ POST [ 'sex'] =总是我看到单选按钮的下面输出:

请参阅=字符串'on'

它始终显示“on” 而不是男性或女性。 这就是我在表格中提出的内容。

我在这里做错了吗?

请帮忙。

如果我使用SELECT框,那么效果很好。 但我需要使用单选按钮使其工作。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dti70601 2017-01-27 08:40
    已采纳
    <form method="post" enctype="multipart/form-data">
    Male : <input type="radio" name="sex" value="male" checked /><br/>
    Female : <input type="radio" name="sex" value="female"/><br/>
    <input type="submit" name="btn">
    </form>
    
    <?php
    error_reporting(0);
    echo $_REQUEST['sex'];
    ?>
    

    Above code is working, Changes

    value = female
    

    you forgot to add = sign

    已采纳该答案
    打赏 评论
  • doubo3384 2017-01-27 08:00
    <input type="radio" name="sex" value="female"/>
    

    you didn't put equal to sign near female.

    打赏 评论

相关推荐 更多相似问题