I'm trying to set a variable to true/false based on the value of a checkbox obtained after submitting a form.
Here's the code I have. When the checkbox is checked it works as expected, but when it's not, the variable ends up being empty instead of false.
HTML
<input type="checkbox" name="checkbox" checked="true">
PHP
if (isset($_REQUEST['checkbox'])) {
$checkbox = true;
echo $checkbox; // echoes true
} else {
$checkbox = false;
echo $checkbox; // echoes nothing?
}
I'm not sure where the issue is, or what I'm doing wrong.