B29: Interactive blogging game: code to cleanse |
Here is the form cleansing code described in my last entry. Here’s a PHP function I whipped up to scan the player name field:
function checkPlayer($in) {
if(strlen($in) < 3) {
errorForm(”player name must be at least 3 characters ($in)”);
}
if(strlen($in) > 15) {
errorForm(’player name must be between 3 and 15 alphanumeric characters. Your submitted name is greater than 15 characters’);
}
if(!ereg(”^[a-zA-Z0-9]+$”, $in)) {
// oops!
errorForm(’player name must be between 3 and 15 alphanumeric characters. Your submitted name contained illegal characters’);
}
}
In my next interactive blogging game entry, it is cookie and file writing time.
Did this post make you go hmm?



