Thread: PHP form
View Single Post
Old 03-11-2009, 11:00 PM   #8 (permalink)
CrazeD
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,690

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: PHP form

Quote:
Originally Posted by office politics View Post
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 ==.
__________________

Need website help? PM me!
CrazeD is offline