zen77us Posted September 14, 2009 Share Posted September 14, 2009 Hi everybody! I just had a quick question about filtering usernames in PHP- can it be done? I am an IT consultant for a small company, and they are contracting out a web developer to build a new site for them. They want to filter inappropriate usernames in their registration form, but their developer has told that that it is impossible to do. They asked me if the developer was being shady and I told them I didn't know (I'm not a web developer myself) but I promised I would research the subject for them. That said: is this possible? I know very basic SQL and PHP stuff, but to my limited understanding it seems like this is theoretically possible and Google has been unhelpful in this search so far. Thank you for taking the time to read my post! Link to comment https://forums.phpfreaks.com/topic/174221-filtering-inappropriate-usernames-with-php-calls/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 14, 2009 Share Posted September 14, 2009 Yes, you can create a list of "bad" words and then test if any part of the entered username is any of the bad words. You should also moderate and review new usernames and either remove or suggest acceptable alternatives. In general, you would remove all characters that don't contribute to the bad word, such as white-space and some punctuation marks. Then, lower-case everything or use a case-intensive search. You would need to have some variations of bad words in the list where different characters could be used as letters, such as 1, !, i, L for l and 0,o,O for o... By limiting usernames to just alphabetic characters, you can eliminate most of the need for these different variations in the list of bad words. Link to comment https://forums.phpfreaks.com/topic/174221-filtering-inappropriate-usernames-with-php-calls/#findComment-918446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.