I would like to accept only small and capital letters from the user.
I tried the below code, it echoes the invalid character message but doesn\'t work. I mean it doe
If you just want to check you could use ctype_alpha() but you said you want to ACCEPT only letters so if you choose to accept the input you could:
$fname=preg_replace('/[^a-z]/i','',$fname);
better after the check