Re: checking if checkbox is checked

From: Date: Fri, 06 Jul 2001 15:08:06 +0000
Subject: Re: checking if checkbox is checked
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-56495@lists.php.net to get a copy of this message
To check if a type checkbox variable has been set use isset() i.e. if ( isset($interest) or isset($interest2) or isset($interest3) or isset($interest4) or isset($interest1) ) { // Everthing is ok } else { $error = ..... ) This should do exactly what you want, and although it may not use the least characters it should be the quickest to write/debug/maintain and run. Regards, George Richard Kurth 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'> > > I am checking for blank field buy doing this below How can I check for at > least one of the above check boxes is checked > > if ($name == "") { > $name_err = " > <font color=red>Please enter your name!</font><br> "; > > $send = "no"; > > } > > Best regards, > Richard > mailto:rkurth@pacifier.com

« previous php.general (#56495) next »