Hey people,
I'm not quite sure how to do this or if I'm going about it the right way so thought I'd ask for some guidence..
What I want to do is allow users to create a username that can use letters, numbers and underscores (_).
So what I started off doing was trying to create an array with all other characters in so that these would be the 'invalid' characters. Then I was just going to say IF username has a character from the array then show an error.
This is what I started doing, but this array shows errors as I'm not sure what characters I should be telling the code to ignore using .
//Create array of invalid characters
$invalid = array(' ','¬','¦','`','!',''','£','$','%','^','&','*','(',')','-','+','=','~','#','{','}','[',']','|','\','\:','\;','\@','\'','<',',','\.','?','/');
Can anyone help me with my array or let me know a better was of doing this?
I did look into preg_match but I didn't understand the patterns to use.
Thanks