"Richard Kurth" <[EMAIL PROTECTED]> wrote:
> I have 5 checkbox's in a form that I what to make sure at least one of
>  the checkbox is checked.
>
> <input type='checkbox' name='interest' value='basic'>
> <input type='checkbox' name='interest3' value='Internet access '>
> <input type='checkbox' name='interest1' value='pro'>
> <input type='checkbox' name='interest4' value='domain name'>
> <input type='checkbox' name='interest2' value='platinum'>

if ( $interest == 'basic' || $interest3 == 'Internet access' || ...
$interest2 == 'platinum' )
{
    echo "At least one was checked.";
}

Ignoring the first input box you could also use a loop since the field names
are sequential.  You could also handle the first field, by starting $i at 0
and only appending $i if it's greater than 0, but I don't want to clutter
the code.  The code below assumes the fields aren't preset to values other
than those listed above.

for ( $i = 1; $i < 4; $i++ )
{
    $field = 'interest' . $i;
    if ( ! empty( $$field ) )
    {
        $flag = TRUE;
    }
}

if ( $flag == TRUE )
{
    echo "At least one was checked.";
}

--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/


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