I have to validate some shit’s in PHP so i did some research and found 2 uber cool snippets to do that:
Mail Validating
if(!preg_match(‘/^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/’, $mail))
die(‘Invalid email proved, the email must be in valid email format (such as name@domain.tld).’);
User Validating
if(!preg_match(‘/^[a-zA-Z0-9_.]{3,16}$/’, $mail])) {
die(‘Invalid username proved, the username must be valid to proceed only “a-z, A-Z, 0-9, _, and .” allowed.’);
}
It will allow the user to imput: a-z, A-Z, 0-9, _, and .
Why PHP when you got tons of JS that can do that you my ask ?
Because i don’t trust anyone
11 January 2010 at 19:49
http://dev.kohanaframework.org/projects/kohana2/repository/entry/tags/2.3.4/system/helpers/valid.php
11 January 2010 at 19:50
PS: luzării ce validează doar în JS și “uită” de serverside o să își ia o mumu epică.