Prev | Current Page 423 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

J., or come from countries where particularly long names
are common, such as the Indian name Swaminathan?
Thankfully, as this section shows, HTML_QuickForm can remove much of the difficulty
involved in data validation. However, even this great package is unable to foresee
what sort of special constraints your user-supplied data will have; so take extra-special
care to think about such matters before putting HTML_QuickForm??™s validation facilities
to work.
Using Filters
HTML_QuickForm provides a means for passing data through a filter, which can perform
any sort of analysis you please. These filters are actually functions, and you can use
any of PHP??™s built-in functions, or you can create your own. For instance, suppose
you are creating a corporate intranet that requires employees to log in using their
employee identification number, which consists of integers and capital letters. For
security purposes you log each employee login, and for reasons of consistency you
want the employee identification numbers to be logged using the proper uppercase
format. To do so, you could install the filter like so:
$form->applyFilter('employeeid', 'strtoupper');
CHAPTER 13 ?–  FORMS 359
?– Note When you are using filters, the user is not notified of any modifications made to the submitted
data. The filter simply executes once the form is submitted and performs any specified actions should the
filter meet the criteria as defined by the function.


Pages:
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435