PHP / Ajax -- Username Availability

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

Have a structure for the script to return, for example, if the suggested username is taken, then return 0|username_06|username_hi|username_OK|blahblahblah

If it's available just return a 1

Idea for suggesting usernames:

Code: Select all

$ideas = array();

$idea = "{$username}_2006";
if ( ! is_taken( $idea ) )
  $ideas[] = $idea;

$idea = "{$username}_n00b";
if ( ! is_taken( $idea ) )
  $ideas[] = $idea;

echo "0|".implode( '|', $ideas );
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Jcart wrote:

Code: Select all

$possibilities = array(
   $username.rand(0,9),
   $username.'_'.$firstname
);
you get the point..
And obviously you you should run these through the DB make sure they are available.
Post Reply