HTML forms are easy to design, as long as you allow one value per field. When you allow more than one value, the processing gets tricky.
Checkboxes are the simplest way to allow users to enter more than one value into a field:
You can check one, two, or all of the pets. The HTML code looks like this:
. When the user clicks the
is 91 in hexadecimal, and the HTML
character entity for left square bracket —
means left square bracket.
means right square bracket.
When we get to the PHP script that processes this form, we use this script to put both values into one field. The PET field is a SET datatype.
checks if the user
checked any of the boxes. If the user doesn't have any pets, the field is left empty.
of the database.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |