I\'m using CodeIgniter and I have a form with a checkbox that allows the user to check and remove their uploaded photo.
In my controller I use if(isset($checked)
remove isset
its because by default in your CI Controller you get input value using
$checked = $this->input->post('remove');
whether is has a value or not your variable now exist..
Please write proper value in your checkbox :-
<input id="remove" type="checkbox" name="remove">
Write some value then check it :-
for e.g :
<input id="remove" type="checkbox" name="remove" value="1">
In php :-
if($checked == 1) {
// do whatever u want
}
Try:
<input id="remove" type="checkbox" name="remove" value="1">
Use this if it can help.
$checked = (isset($_POST['checkbox']))?true:false;
What you need to do here is to change this line ...
if(isset($checked) == 1){
to
if((int) $checked == 1){
The reason is that the variable $checked will always be set whether its value is 1 or not. $checked = $this->input->post('remove');
will return NULL if the 'remove'
is not set in the POST data.