Answer the question
In order to leave comments, you need to log in
Options for free logins during registration. What algorithm?
Situation:
A person registers on the site, but the selected login is already taken.
Task:
Offer the user (generate) several login options that are guaranteed to be free. At the same time, these options should be more or less meaningful. Not a random set of characters.
Problem:
How to do it (algorithm)? My option is this.
1. Let's say the login is "dima". Find in the database all logins containing the substring "dima" and put into an array.
2. We generate supposedly free logins by adding some predefined characters to the beginning and / or to the end of the desired substring. For example, "mr.dima", "dima-2014", etc. These logins are placed in the second array.
3. We are looking for logins from the second array in the first array. Those that are not found are offered to the user.
The approach seems to be working, but still I would like to hear the opinion of professionals. Perhaps you have already done something similar? How is it done for you?
Answer the question
In order to leave comments, you need to log in
1. It seems to me that this item will be quite expensive if the database is large, especially if you search like this: WHERE login LIKE "%dima%".
As for me, it's better to first create a list of offers, and then check which of them are in the database: WHERE login in ('...', '...', ...)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question