Issue
Building a proof-of-concept web site for a group project. Regarding usernames we would like to:
- register and display the name with case e.g "BillyBob1"
- prevent users from duplicating names using characters with alternate case e.g. "billybob1", "BILLYBOB1", "bIlLyBoB1" would be considered duplicates if user "BillyBob1" already exists
- during login, allow the user to enter their username without concern for case e.g. can type in "billybob1" into the username field but still be recognized as "BillyBob1".
String comparisons in MySQL, using the default character set and collation, are case-insensitive, so conceptually this is easy. Save the the usernames in a VARCHAR column, then use a standard search to determine duplicate registration attempts and to confirm usernames regardless of case used. Simple. Almost...too simple.
But looking around for a minimal best practices guide for handling usernames (and passwords) on a *AMP-based web application didn't turn up much. Can anyone point us in the right direction to before we try reinventing the wheel?
Solution
There isn't much of a wheel to reinvent. You are already on your way to a minimal solution.
Store the username in varchar with a _ci collation and you should be fine with your case issues.
Store passwords with any of the encrytion methods inside mysql, PASSWORD() is one of them.
Answered By - Andreas Wederbrand
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.