I have a form with an input "username". I would like to strip special characters out of the username before it is inserted into my DB. I currently have:
Which removes multiple whitespaces and converts them into one, but how can i modify it to remove special characters aswell? When i say special characters i mean stuff like:
-_!"£$%^&*()#~`¬¦€
I ONLY want a person to be able to have a-z, A-Z, and 0-9 in their username...help?! How do i change that line to incorporate removing the special characters? I dont want hypens or underscores either!
Code:
$username = preg_replace('#\s+#s', ' ', $username);
Which removes multiple whitespaces and converts them into one, but how can i modify it to remove special characters aswell? When i say special characters i mean stuff like:
-_!"£$%^&*()#~`¬¦€
I ONLY want a person to be able to have a-z, A-Z, and 0-9 in their username...help?! How do i change that line to incorporate removing the special characters? I dont want hypens or underscores either!