Helping ordinary people create extraordinary websites!

Using HTML Forms With PHP

By Nicholas Chase
2004-01-09

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
}
...




Tutorial pages:

First published by IBM developerWorks


 2 Votes

You might also want to check these out:


Leave a Comment on "Using HTML Forms With PHP"
You must be logged in to post a comment.

Link to This Tutorial Page!


GET OUR NEWSLETTERS