Jump to content
Larry Ullman's Book Forums

How To Get And Validate Data From Check Boxes?

Recommended Posts

I am trying to create a form with check boxes so the data will be sent by email.


When two boxes are checked, only one value is passed.


Can you show me how to get and validate check boxes data so I can use a booking form on the website?


Thank you

Link to comment
Share on other sites

// Process checkbox:

if(isset($scrubbed['service'])) {

$service = $scrubbed['service'];


} else {

$service = NULL;

$errors[] = "<p class=\"errors\">Please check some of the boxes. </p>";



<fieldset class="checkbox">

<p>Service type: </p>



<li> <input type="checkbox" name="service" id="service-one" value="one" />

<label for="service-one"> service-one </label> </li>


<li> <input type="checkbox" name="service" id="service-two" value="two" />

<label for="service-two">service-two </label> </li>


<li> <input type="checkbox" name="service" id="service-three" value="three" />

<label for="ervice-three"> service-three</label> </li>


<li> <input type="checkbox" name="service" id="other-service" value="other-service" />

<label for="other-service"> Other </label> </li>



Link to comment
Share on other sites


  • Create New...