Everyone, hello!
I'm trying to tick/untick a HTML checkbox with help from my PHP code.
The option if a checkbox has to be ticked or unticked I get from a config.ini file, which looks like this:
config.ini
[com]
p_ip = x.x.x.x.
p_port = xxx
p_username = xxx
p_password = xxx
[trigger]
string1_enable = no
string2_enable = yes
string3_enable = no
And I've activated the config.ini file in my index.php file as such:
index.php
<?php $ini = parse_ini_file('config.ini'); ?>
Now, as far as the HTML is concerned, I've tried this:
<td><li><input type="checkbox" class="categories-checkbox" name="chk2" id="chk2"<?php if ($ini['string2_enable']=="yes") echo 'checked="yes"';?>><label for="chk2">Enable</label></li></td>
It doesn't throw an error, but it certainly won't enable. However, a simple:
<?php $ini = parse_ini_file('config.ini'); ?>
<?php echo $ini['string2_enable']; ?>
yields a yes on my PHP page.
Any help would be greatly appreciated!
checked='yes'show up in the generated html? If not, then make SURE that what's coming out of the ini parse is really just the three lettersy,e,s, and doesn't contain extra stuff, like spaces or line breaks or whatever. e.g.var_dump($ini)and see what actually parsed out of there.var_dump()instead ofechoin this case, to ensure what @MarcB is saying.