Results 1 to 2 of 2

Thread: Question about putting stuff in MySQL Tables.

  1. #1
    Join Date
    Mar 2003
    Posts
    1

    Question about putting stuff in MySQL Tables.

    Im running PHP on MySQL, im running a script that when a user signs up.. It picks a random number between 1 and 200, uses that number as an ID to read from a table on the SQL. In that table, there are 200 words that are to be used as controled starter passwords.

    I'm trying to figure out how to get the words into the table so that it can call upon them, but I have no idea how to put the passwords in the table.

  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145
    From what I understand this is more a conceptual problem then anything else. Here is how I would do it:

    Step 1 : User registeres from a standard web based form. In the end, our registration script will have $username and other info. Assuming all other validation rules pass, we continue to Step 2.

    Step 2 : The registration script creates a random password based on dictionary words. On my Linux system I use a little Perl script that does the password generation:

    #!/usr/bin/perl

    @ARGV = ('/usr/share/dict/words') unless @ARGV;
    srand;
    rand( $. ) < 1 && ( $word1 = $_ ) while <>;
    chomp( $word1 );

    @ARGV = ('/usr/share/dict/words') unless @ARGV;
    srand;
    rand( $. ) < 1 && ( $word2 = $_ ) while <>;
    chomp( $word2 );

    $word3 = int( rand( 99 ) + 11 );
    $password = $word1 . $word2 . $word3;

    print "$password\n";

    exit;
    This script will produce output like "skaterslender50". I store this value in $password

    Step 3 : Capture the password's MD5 in the DB:

    INSERT INTO usertable ( username, password ) VALUES ( '$username', MD5( '$password' ) );
    Step 4 : Mail the original password, still in $password, with more instruction to the user's e-mail address.

    I hope this helped somewhat.

    Cheer

Posting Permissions

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