I'm not sure why this function is not working. I have a bit of logic works fine, but when I tried to move that into a function it didn't work! No idea why!!
Please look at my code:
function check_checkbox_value($value) {
if (!empty($value)) {
return "checked";
}
}
?>
<form method="get" action="">
<br />Upper: <input type="checkbox" name="upper" <?php if (!empty($_GET['upper'])) { echo 'checked';} ?>>
<br />Lower: <input type="checkbox" name="lower" <?php echo check_checkbox_value($_GET['lower']); ?>>
<input type="submit" name="submit" value="Generate">
</form>
It's clear that the first input (upper) works (no Notice: Undefined index error when it's not checked/set), However the second input display the error when it's not set, I thought I moved that functionally to a function and returned the checked value and echo it.
Why the function doesn't work? Any ideas? Thank you so much!