Server-side validation

Server-side data validation means using PHP to verify that good values have been sent to the script. Using server-side validation has pretty much the exact opposite pros and cons of client-side development: it is more secure and works seamlessly with all browsers, but it does so at the cost of slightly higher server load and slower feedback for users.

One big advantage to server-side validation is that you can use PHP - a language by now you have attained some skill with. As you know, PHP has a wide variety of functions and language features to help you chop and change strings, check numbers are within ranges, and so on. Furthermore, you can use PHP to connect to a database to check whether a username exists, for example, which is simply impossible using client-side scripting.

 

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Validation in practice >>

Previous chapter: Client-side validation

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.