If option selected do this or this on form
I have the following options:
<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>
and I have these two lines to send data from two fields, now if the options arn't selected then I don't want the content being sent to these fields so they need some conditionals around them that check if an option is selected or not:
$post_url = $_POST['post_url'];
$post_code = htmlentities($_POST['post_code'], ENT_QUOTES, 'UTF-8');
so only post the URL field if the link option开发者_开发技巧 is chosen and only post the CODE field if the code option is chosen. can anyone help?
Check the value of the button(only the checked button will be submitted) , it might be 12, 13 or 14.
Example for the link:
if(isset($_POST['post_category']) && $_POST['post_category']==14){
//do it with the link
}
精彩评论