PHP class based form checking
Friday, July 6th, 2007Once upon a time I decided to make a php script. The script was a simple test. Users could could submit data, that was later spewed out along with everyone else’s submissions. I was quite beside myself. I had hundreds of entries, and I thought things were going quite well! Oh how naive! The next day a strange yellow box that said “don’t mouse over me” appeared on the list. Of course I couldn’t help myself, and moved my cursor straight towards the box. The next thing I know I’m being redirected to the homepage for a professional Christian wrestling organization. It was at this point that I realized you shouldn’t trust everything users put into an input box. I quickly devoted myself to fixing the issue trying to find the best way to validate forms. Several months later after many various attempts I was able to devise a class based system that made form checking a breeze. Now I’m about to divulge everything I have learned to you in a matter of minutes! I’ll start off with the basic form checking strategy, describe how classes can simplify this process, and end with some general guidelines and tips.
