I am making a simple web form in codeigniter but facing a problem with radio button.
I have added two radio button. one is working perfectly, but the other one isn't
This is View:
<div class="form-group">
<label for="wai_banner_photography">Would you like to include photography in your website's banner?</label><br>
<input type="radio" name="includephotography[]" value="yes"/> <label>Yes</label><br>
<input type="radio" name="includephotography[]" value="no" /> <label>No</label><br>
</div>
<div class="form-group">
<label for="wai_provide_stockimage">Would you like us to provide you with suitable stock images?</label><br>
<input type="radio" name="providestockimage[]" value="yes"/> <label>Yes</label><br>
<input type="radio" name="providestockimage[]" value="no"/> <label>No</label><br>
</div>
This is Controller part for collecting data:
$include_photography = $this->input->post('includephotography');
echo "26 ";
print_r($include_photography);
echo "<br/>";
$pprovidestockimage = $this->input->post('providestockimage');
echo "27 ";
print_r($pprovidestockimage);
echo "<br/>";
The output i am getting is:
I think, i am missing something small. Any help will be appreciable.
Thanks in advance.
Radio buttons used to return one value so their name must not be an array like this
name="includephotography[]"
it must be
name="includephotography"
and after this you must use
echo $include_photography;
instead of
print_r($include_photography);
may be this will help
Radio button willl post value only if any one of them is selected.
You might have selected radio button in first case but not in second case.