[FX.php List] User exists - offer other names

Steve Winter steve at bluecrocodile.co.nz
Wed Aug 22 10:55:10 MDT 2007


Hi William,

An interesting challenge... a few options to consider... once you know the
name isn't available you could...

1. download every existing username into a PHP array, generate suggestions,
test to see if they are in that array, if not, add them to the list until
you have 5. pro - only one call to the db, con - once you have a lot of
users, it's a BIG array and may take a while to process

2. generate a suggestion, perform a lookup in the db for that suggestion, if
it's not found add it to the list, and repeat till you have five options on
the list pro - doesn't matter how big the db gets, con - requires 6 hits to
the db

3. a modification of 1, define that all of your suggestions are going to use
the exact username that the person requested, then append other characters
to it, so create an array of all usernames which have those characters as
the beginning of them, then generate options and test against that array...
pro - doesn't matter how big the db gets, only requires 2 db calls, con -
none that spring to mind

This seems the best way to go to me so I'll give an example;

Current usernames in database;
  .
  .
  .
  steveSmith
  steveSmithson
  steveWinter
  steveWinterNZ
  steveWinter1970
  steveYeates
  steveYeateson
  .
  .
  .

User requests steveWinter

It already exists, so your second request to the db is 'find all usernames
beginning with steveWinter and load them into an array called $currentNames'

Generate a suggested username, depending on what other data you asked them
for you could use options like appending their country code, their year of
birth, the place they live etc... or if you don't have any other personal
data, you could just use a sequential number, the current year, the current
day, whatever...

Once you've made up a username test it against the array of current ones, if
it's not in there add it to a new array of suggestions, until that array has
5 items...

Hope this helps... if you want to follow this through and need help with
coding this get back to us...

Cheers
Steve


-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of William Downs
Sent: Wednesday, 22 August 2007 10:07 a.m.
To: FX.php Discussion List
Subject: [FX.php List] User exists - offer other names

Hi guys,

I'm looking for something here and have no idea where to start !

I am building a DB where a user can enter themselves - contact data
and user name.
I am looking for a way to say "This user name is already taken. Please
enter another name"

This I can do - what I CANNOT do is offer them a selection of names (5
possibilities) that also do not exist !

Example entered:
User name = wills
Returns:
This user name is already taken. Please enter another name. Possible
examples are
wills100
wills200
wills300
wills101
wills202
Or enter an entirely new name.

Of course, none of the above 5 names exist either.

Any ideas ?

William
_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.484 / Virus Database: 269.12.1/965 - Release Date: 21/08/2007
4:02 p.m.
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.484 / Virus Database: 269.12.1/965 - Release Date: 21/08/2007
4:02 p.m.
 




More information about the FX.php_List mailing list