B28: Interactive blogging game: user input cleansing |
Allow me to bitch and moan about how it sucks having to treat every piece of user input like it’s garbage or a malicious hack, but if you don’t then you will have all kinds of coding problems.
Fortunately there are some built-in PHP functions that help you deal with cleansing user form input like: htmlspecialchars, htmlentities
In the three fields I’m using, I just want to allow specifc data (see last entry screenshot).
Player Name - alphanumeric only, 15 characters max
Password - alphanumeric only, 10 characters max
E-Mail Address - valid email address
I’m going to amend the password to be a minimum of 6 characters. Through the use of the functions strlen (get the length of a string) and some basic regular expression handiwork I’m going to force this user input checking. I know that some folks use JavaScript to do this, but you still have to check form input on the server side. I’m going to go work up this code. I’ll share in my next blog entry.









Boy, this egg timer sure sucks! It isn’t reliably ticking off the minutes like it should. It’s a good thing I have other timers running. I saw somebody suggest that and I wouldn’t recommend using an egg timer for anything important. What a piece of crap.

