Forum Moderators: coopster
But for now i was hoping if there were some scripts or examples of ways to validate user input into forms. What things should i be checking for. Like SQL injection?
thanks for your time
-Mark
You might also find the following useful:
[phpsec.org...]
Chris Shiflett`s website is also full of useful tips:
[shiflett.org...]
dc
only allow expected values and if there is anything that comes that is not in the expected set then send the whole thing back to the user to correct ...
I would emphasize this point.
You should know pretty well what kind of data will sow in each field on a form. Screen each field by type (alpha, numeric, both, etc.) and length. A US zip code, for instance, will either be 5 digits or 5 digits, a hyphen, and 4 more digits. A phone (depending on filed layout) 3 digits, 3 digits, and 4 digits.
I like to screen browser side first, and then again server side. It is possible to "auto-correct" some entries doing this, such as stripping or converting "alternate" characters (periods rather than hyphens in a phone number, spaces in a credit card number, etc.).
Use meaningful error messages for the user.
Be prepared for odd things like accented letters, hyphens or apostrophes in names (O'Donnell, Smith-Barney, etc.).
Your error checking routines will probably end up being a significant percentage of your code.