Validating php

Rated 3.92/5 based on 665 customer reviews

If the REQUEST_METHOD is POST, then the form has been submitted - and it should be validated.

If it has not been submitted, skip the validation and display a blank form.

Validation means check the input submitted by the user.

I would not put any constraints on a user name - it may even contain numbers; think of aristocratic names. No matter what regex you come up with, I can find a name somewhere in the world that will break it.

However, in the example above, all input fields are optional.

Although this seems like a trivial question, I am quite sure it is not :) I need to validate names and surnames of people from all over the world. If it were only English ones I think that this would cut it: I doubt that this is feasible - there are just to much Unicode symbols to exclude all unwanted symbols (and how will tell you what Chinese symbols to exclude?

HP 5.3.3 and 5.2.14 had a bug ( related to FILTER_VALIDATE_EMAIL, which resulted in segfault when validating large values.

Simple and safe workaround for this is using strlen() before filter_val().

Leave a Reply