PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 12, 2022

[FIXED] Best practices for handling usernames on an *AMP-based web application?

 January 12, 2022     case-sensitive, lamp, mysql, php     No comments   

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
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing