[EMAIL PROTECTED] wrote:

> In am HTML form, checkboxes NOT checked are not passed
> to the PHP script called by the form.
> 
> Therefore, if $name_of_chechbox_3 is not passed but it's
> used in the PHP script, it results in "Warning:
> Undefined Variable".
> In am HTML form, checkboxes NOT checked are not passed
> to the PHP script called by the form.
> 
> Therefore, if $name_of_chechbox_3 is not passed but it's
> used in the PHP script, it results in "Warning:
> Undefined Variable".
> 
> How can I avoid this?

As suggested, using isset($name_of_checkbox_3) is a Good Idea (tm).

Suppressing the error message with @ is hacky, but will work and is less to 
type.  Not nearly as "professional" looking, though.

That said...

Usually, the checkboxes are grouped together of multiple options, and you 
really ought to give them more meaningful names than name_of_checkbox_3...

So, what *I* usually end up doing is having stuff like:

... CHECKBOX NAME=colors[1] VALUE=red ....
... CHECKBOX NAME=colors[2] VALUE=blue ....
... CHECKBOX NAME=colors[3] VALUE=green ....

Then, in the processing script, I use:

while (list($id, $color) = each($colors)){
        // Deal with $id, $color passed in  -- Others were not passed in
}

If it really is just a one-off CHECKBOX and not a group, by all means stick 
with isset()

-- 
Like music?  http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to