phppup Posted February 27, 2012 Share Posted February 27, 2012 While we're on the subject, is there a way to ensure that the first letter of a name is captalized, and the rest lowercase? Or is this best handled later on, when the name is being used and called from the DB. PS: some of us comment are code as to WHAT we are doing because we're just not that good yet, and we need to explain it to ourselves. Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/ Share on other sites More sharing options...
Pikachu2000 Posted February 27, 2012 Share Posted February 27, 2012 Why would you force capitalization on a username? Let the user capitalize it the way they want. Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321693 Share on other sites More sharing options...
phppup Posted February 27, 2012 Author Share Posted February 27, 2012 I might want it capitalised so that when I send an email, it can be addressed "Dear Greenballoon" as opposed to greenballon. So, is there a way to do it, or it it best left until I send the email. Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321697 Share on other sites More sharing options...
Pikachu2000 Posted February 27, 2012 Share Posted February 27, 2012 I might want it capitalised so that when I send an email, it can be addressed "Dear Greenballoon" as opposed to greenballon. So, is there a way to do it, or it it best left until I send the email. But the username the user picked is greenballoon, not Greenballoon. Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321711 Share on other sites More sharing options...
phppup Posted February 27, 2012 Author Share Posted February 27, 2012 So how would I ensure that a name field is SAVED with the first letter capitalized, and the rest all lowercase, regardless of how it was typed into the field? Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321715 Share on other sites More sharing options...
phppup Posted February 27, 2012 Author Share Posted February 27, 2012 No numbers, no characters, just a capitall lettter and the remaining lowercase letters. Also, if I want toeveviate some of the PHP burden and add this in Javascript, should it go directly ahead of the PHP, or be intertwined with it? Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321716 Share on other sites More sharing options...
batwimp Posted February 27, 2012 Share Posted February 27, 2012 I agree with Pikachu2000. Forcing capitalization on user names is a bad idea. This could end up causing a lot of problems down the road. People select their user names knowing that it is case-sensitive. Why would you mess with that, even in an email salutation? Many times I have forgotten what user name I used for a particular site, and copy-pasted it from an email I received from that site. If I got denied access, I would think it was because of a password issue, not username. Yeah, bad idea. Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321721 Share on other sites More sharing options...
batwimp Posted February 27, 2012 Share Posted February 27, 2012 But if you insist on doing this anyway, try using the ucfirst() function. http://us3.php.net/manual/en/function.ucfirst.php Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321734 Share on other sites More sharing options...
Pikachu2000 Posted February 27, 2012 Share Posted February 27, 2012 ucfirst doesn't do anything to any character other than the first one. You'd have to first strtolower the string. And if you do that, then what happens to the person whose username is MacDonald_II? Do you see why there are far more reasons not to do this than there are to do it? Quote Link to comment https://forums.phpfreaks.com/topic/257875-username-capitalization-split-from-allowable-characters-for-username/#findComment-1321816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.