Using HTML Forms With PHP
By Nicholas Chase
2004-01-09
Reader Rating:

The Amazing Disappearing Checkboxes
It's important to realize that a checkbox is only submitted if it's actually checked. Otherwise, its very absence tells you what you need to know: the user didn't click this checkbox. In the case of checkboxes, you can check explicitly to see whether the value was set using the isset() function:
Listing 7. Checking to see if a checkbox was submitted
...
$contact_value = $HTTP_GET_VARS['contact'];
echo $contact_value;
if (isset($contact_value)) {
//The checkbox was clicked
} else {
//The checkbox wasn't clicked
}
...
|
First published by
IBM developerWorks
If you found this article interesting, you may want to read these as well:
» Protecting your PHP and HTML Source Code
» Publishing Newsletters Using PHP & MySQL - 4
» Publishing Newsletters Using PHP & MySQL - 3
» Publishing Newsletter Using PHP & MySQL - 2
» Publishing Newsletters Using PHP & MySQL
» Unix Webserver Crontab Basics
|