dream0614 2015-01-23 06:47
浏览 5
已采纳

使用PHP检查是否在服务器端检查单选按钮[关闭]

I am displaying a form to a user with some content and a few radio buttons. How can I know which radio button is checked on server-side after user clicks on submit button in form?

I don't know why it has been marked negative. I searched on google about it but could find nothing. If it is not possible just say can't be done otherwise tell me how it could be done. I am posting some code but I don't think that would help

<input type="radio" name="meme" id="woman" class="input-hidden" />
<label for="woman"><img class="memeimage" src="url1" alt=""/></label>
<input type="radio" name="meme" id="man" class="input-hidden" />
<label for="man"><img class="memeimage" src="url2" alt=""/></label>

Should the PHP code be something like

if(empty($_REQUEST['meme'])) but how will that tell me which radio button is checked.
  • 写回答

2条回答 默认 最新

  • drkj41932 2015-01-23 06:54
    关注

    Give radio button value like:

    <input type="radio" name="meme" id="woman" class="input-hidden" value="woman"/>
    <input type="radio" name="meme" id="man" class="input-hidden" value="man"/>
    

    If you use this:

    $_REQUEST['meme']// output man / woman
    

    You can check like this:

    if(isset($_REQUEST['meme'])) {
      //radio selected
      echo $_REQUEST['meme'];// will output man / woman
    } else {
    echo "nothing was selected.";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题