PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
For my registration page, i don't want the user to be able to use 'bad' characters, ie, only [a-z], [A-Z], [0-9], [_], [-] should be allowed.
But how could i check if there are any 'banned' characters in the requested username?
Last edited by vigge89 on Sat Jan 31, 2004 3:59 am, edited 1 time in total.
You could use regular expressions. Someone who knows about them should be able to pop one out really quick. I am not one of those people so I would use PHP's string functions. Break the username down character by character and compare that character against legal characters. Dirty I know, but it works.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Normally, preg_match on /[a]/ would return true of there was an 'a' in the string
the [^a] returns true if there is a character different from 'a' in it.