2011-03-18 51 views
1

我有以下选择:如果所选的选项做这做这个表格上

<li><label for="r1"><input type="radio" name="post_category" id="r1" value="12" checked="checked" /> Share an Article</label></li> 
            <li><label for="r4"><input type="radio" name="post_category" id="r4" value="14" /> Share a Link</label></li> 
            <li><label for="r3"><input type="radio" name="post_category" id="r3" value="13" /> Share some Code</label></li> 

,我有以下两行由两场发送数据,现在如果arn't选择的选项,然后我不不想内容被发送到这些字段,以便他们需要周围的一些条件语句如果一个选项被选择或者不就是检查:

$post_url = $_POST['post_url']; 

$post_code = htmlentities($_POST['post_code'], ENT_QUOTES, 'UTF-8'); 

所以只有选择了链接选项后的URL字段,只张贴代码字段,如果选择了代码选项。谁能帮忙?

回答

2

检查按钮(仅选中的按钮将被提交)的值,它可能是12,13或14

示例链接:

if(isset($_POST['post_category']) && $_POST['post_category']==14){ 
//do it with the link 
} 
+0

,所以我居然把我的' $ post_url = $ _POST ['post_url']'里面你把评论的权利? – Cameron 2011-03-18 01:43:34

+0

是的,只有在“共享链接”按钮被选中时,您才会处理的说明。 – 2011-03-18 01:45:36

相关问题