Quote:
Originally Posted by office politics |
Defining a value is optional.
PHP Code:
<?php
$check = $_POST['checkbox'];
if ($check == true) { echo 'true<br />'; }
if ($check == 'on') { echo 'on<br />'; }
if ($check) { echo '$check<br />'; }
echo '<br /><br /><form action="checkbox.php" method="post">
<input type="checkbox" name="checkbox" /><input type="submit" name="submit" value="submit" />
</form>';
?>
In this script, all of the if's work. If you give the checkbox a value, then you need to change == 'on' to the value.
In any case though, he only had one = when he should have had ==.