Reputation: 2824
I have given 2 option(upload icon/select icon) in form, but when i am checking it with php its throwing error...
html
<label class="tagslabel">Upload Icon</label>
<input name="uploadicon" type="file" />
<span>or</span>
<ul class="icons clearfix">
<li>
<input type="radio" value="123456" name="selecticon"/>
<label for="selecticon">
<img src="pics/123456.jpg" alt="123456" width="34" height="34" />
</label>
</li>
<li>
<input type="radio" value="654321" name="selecticon" />
<label for="selecticon">
<img src="pics/654321.jpg" alt="654321" width="34" height="34" />
</label>
</li>
</ul>
php
if (!empty($_FILES['uploadicon']['name'])) {
//do image processing and validation
}
else {
if($_POST['selecticon'] == '') $errors['selecticon'] = 'Please Select An Icon or upload Icon!';
}
but its throwing following error, if i upload image instead of selecting one.
Notice: Undefined index: selecticon
Upvotes: 0
Views: 47
Reputation: 6106
It's possible that the user selects neither of your options, nor uploads a file themselves. In which case you should check for the existence of 'selecticon' in the $_POST superglobal. Something like this:
if(!isset($_POST['selecticon'] || $_POST['selecticon'] == '') $errors['selecticon'] = 'Please Select An Icon or upload Icon!'
Upvotes: 0
Reputation: 7223
Try changing
if($_POST['selecticon'] == '')
to
if (!isset($_POST['selecticon']))
Upvotes: 4