I have a user registration script where they enter their username and other details. I am going to have their profiles accessible at domain.com/username What do I need to do to the username to make it safe for the url? I know I need to use str_replace() and I know how to - I just want to know what characters I need to strip out. Thanks
If I were doing it I would strip all whitespace, and anything except letters and numbers. You can technically have -'s and _'s in there if you want. This should work: preg_replace("/[^a-zA-Z0-9 ]/","",$string); //if you want dashes and underscores **Not sure if you need to escape - or _ preg_replace("/[^a-zA-Z0-9\-\_ ]/","",$string); PHP: