Validating Values

It’s not enough to know which technique should be used to process form input; you also need to know what sorts of things you can validate in form fields. In the sample script, I checked to make sure that the user entered something in each of the fields. That sort of check is better than nothing, but it doesn’t really do much to ensure that the user entered the type of data that you expected in the field.

In some cases, validation beyond making sure that the field is populated is unnecessary. For example, if you’re just letting users enter feedback about the Web site, it’s not so important what they enter in the form field for comments. Or, such a wide variety of values is allowed that there’s no reliable way to make sure that ...

Get Sams Teach Yourself CGI in 24 Hours, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.