Chapter 7. Validation on the Server and Client

Validation is essential to web database applications. Ensuring that data meets user and system requirements is important, but ensuring that the database constraints are met by the data is critical. There are three possible data environments in which validation can occur in a three-tiered web database application: in the DBMS, in server-side scripts, and on the client. We discuss the merits and possibilities of these approaches to validation in this chapter.

As the name suggests, client-tier validation occurs at the client browser before a request is sent to the server and is usually validation of <form> data. The most common way to implement client-tier validation is using the scripting language best known as JavaScript. JavaScript isn’t a fully fledged programming language, but it’s one that can be effectively used for simple tasks such as validation. The drawback of validation at the client is that it depends on the user and his environment: the user can disable JavaScript, and can willfully or passively circumvent the validation, and the client environment isn’t usually managed or standardized by the developer of the web database application.

Server-side validation is usually performed in a middle-tier script and is the essential validation tool. When data is inserted, updated, or deleted at the DBMS, it’s undesirable to rely on the constraint-checking validation implicitly performed by the DBMS in the database tier. Trapping errors ...

Get Web Database Applications with PHP, and MySQL 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.