The Importance of Server Side Form Validation with PHP

One important feature of HTML5 is improved form input types. This makes client side validation easy. Now we can validate emails, urls, and phone numbers without using JavaScript. This can make it tempting to use rely on the client side and use lax server side validation. Especially when you need to finish your project quickly.

This is one of the biggest mistakes you can make in your development process. You should never ever skip server side validation. Client-Side validation is useful because it can give visitors quick feedback when data is invalid, but its mostly a convenience. A malicious user can simply turn off JavaScript, add no-validate to your HTML5 and send through any data they want.

This malicious data may be anything from spam to code that erases your database and ruins your client's entire website. Even spam data can take a lot of time to sort through and remove.

To save time and make your development process easier, I recommend creating a reusable validation class. Add methods for each type of data you want to validate. This way you can use it on all of your projects and you will not have to worry about having to skip server-side validation in favor of making a project deadline. If you are familiar with the Laravel PHP framework you have probably used their validation class.

Check back for a tutorial that will walk you through creating a reusable PHP validation class.

Need Help with Your Website

If you need help with your website contact me here.

© 2023, Elizabeth Rogers All Rights Reserved