Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    14

    Unanswered: Random Username Generator

    Hi, i 'm trying to create a random username generator that will take the the firstname and last name entered in a form, add them together and place a random 6 digit number on the end.

    Example: PeterCook728291

    Any help would be great..........


    Many Thanks

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    You can use the timestamp returned from the Time() funtion with fmod() or bcmod() with a dvisor of 1,000,000 to give the remainder (modulo) ######, value for your random number.

    <?php
    $ufname = "French";
    $ulname = "Fry";
    $randts = bcmod(Time(),1000000);

    echo $ufname.$ulname.$randts;
    ?>

    If you expect very high traffic for username generation you should impliment an flock file or some other method to prevent two exact times being posted.


    ~
    ~

    Bill

  3. #3
    Join Date
    Jan 2005
    Posts
    14
    Thank you very much, it works great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •