...and i'd like to hear some comments how do u handle this.
Lets say you had a telephone no input box, and you set the html to MAXLENGTH that at 15 chars.
PHP Code:
if ( strlen( $_GET['tel']) > 15 ){
// abort everything, and redirect
}
As you say, that could be 2GB of data they sent you, whether they send 16 chars or 16 million - someone's messsing about.
OK. so you stipulate that they can only send numbers and spaces in the Tel input box.
Run a simple regex over it, right?
But what I would do before the regex is to replace and letter 'o' with a number '0' because that's the kind of mistake my mom would make.
Hence I don't wholeheartedly agree with this statement:
You shouldn't really accept code from a user in a non-valid way, and filter it to say "o I guess you meant this?". Its just not a good practice. Validate everything from the user to make sure its in the format you're expecting. Data filtering should be limited to make sure that its escaped correctly and safe for storing.
So THEN I'd verify there was only numbers and spaces and for good measure I'd *_real_escape_string() it as it goes in the db, because even I make mistakes.
Now which is termed as filtering and what is validating I am not sure.
Bookmarks