What is the best way to check if a Check-Box is checked?!
Here is my HTML...
Code:
<input name='selectAll' type='checkbox' value=1 />
In my PHP, I originally had been using this...
PHP Code:
if (!empty($_POST['selectAll']) && $_POST['selectAll'] == 1){
However, in retrospect this seems like overkill...
If the Check-Box was not checked, then it would have a value of "NULL", right?
And if the Check-Box was checked via the Form, it would have a value of "1", right?
And if some hacker were screwing with things, it would have some other value, right?
But in this instance, all I really care about is if selectAll = 1, so couldn't I just write this instead...
PHP Code:
if ($_POST['selectAll'] == 1){
// Do something.
}else{
// Do nothing.
}
Sincerely,
Debbie