Checkboxes
What to use checkboxes for
Checkboxes provide the user with a way to select one or more options from a group. For example they may like several different sports, genres of music or authors.How to use checkboxes
<input type="checkbox" name="name" value="this-value">
name - This name identifies a group of checkboxes.
this-value - This is the value to be submitted if that particular checkbox is among those selected.
For example;
<form action="form-process.php" method="get">
<input type="checkbox" name="hobby[]" value="sport"> I enjoy sports<br>
<input type="checkbox" name="hobby[]" value="reading"> I enjoy reading<br>
<input type="checkbox" name="hobby[]" value="music"> I enjoy music<br>
<input type="checkbox" name="hobby[]" value="writing"> I enjoy writing<br>
<input type="checkbox" name="hobby[]" value="watching films"> I enjoy watching films<br>
<input type="submit" value="Submit">
</form>
<input type="checkbox" name="hobby[]" value="sport"> I enjoy sports<br>
<input type="checkbox" name="hobby[]" value="reading"> I enjoy reading<br>
<input type="checkbox" name="hobby[]" value="music"> I enjoy music<br>
<input type="checkbox" name="hobby[]" value="writing"> I enjoy writing<br>
<input type="checkbox" name="hobby[]" value="watching films"> I enjoy watching films<br>
<input type="submit" value="Submit">
</form>
Note that when using PHP to deal with the form results you must add [] after the name of the checkbox. This lets PHP know that it is an array - more on dealing with forms using PHP is covered in the PHP tutorials.


