View Single Post
Old 01-05-2013, 05:28 PM   PM User | #3
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
If a checkbox is not checked then nothing at all is posted-back: the post value will not be set (or even exist).

POST data are strings (or arrays of strings), unless you do some conversion to a number, etc., so you should compare against '1'.

PHP Code:
if (isset($_POST['selectAll']) && !empty($_POST['selectAll']) && $_POST['selectAll'] == '1') { 
Most people tend to omit the second of these tests. But we can now do:

PHP Code:
if ($_POST['selectAll'] && $_POST['selectAll'] == '1') { 
where the first expressions says, effectively, "it exists and has a value"; that is, a value other than a falsy-value.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote