Create passwords for multiple records (PHP/mySQL)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • wozza

    Create passwords for multiple records (PHP/mySQL)

    hi

    I'm a Dreamweaver user who's created a few simple data entry/
    registrations forms in my time, but I'm not really a coder (though I
    can follow instructions and am not afraid to dabble...) - I generally
    make use of DW's builtin commands and some extensions.

    Anyway I'm creating a registration site for event exhibitors and I've
    been asked to come up with a method of automatically generating
    passwords for inserted records, either as they're inserted or at some
    point later (i.e. some kind of mass password creation). Is there a
    recognised way of populating multiple records' password fields with
    random passwords (say 8 characters long)?

    A couple of possible complications.. .

    1. The client wants to be able to insert the rest of the exhibitor
    data via a CSV upload (I'm using a Dreamweaver extension for this -
    http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
    creating individual records manually via the registration site.

    2. They've also asked that the password avoids letter 'O' and numner
    '0'.

    Thanks in advance!
  • Jerry Stuckle

    #2
    Re: Create passwords for multiple records (PHP/mySQL)

    wozza wrote:
    hi
    >
    I'm a Dreamweaver user who's created a few simple data entry/
    registrations forms in my time, but I'm not really a coder (though I
    can follow instructions and am not afraid to dabble...) - I generally
    make use of DW's builtin commands and some extensions.
    >
    Anyway I'm creating a registration site for event exhibitors and I've
    been asked to come up with a method of automatically generating
    passwords for inserted records, either as they're inserted or at some
    point later (i.e. some kind of mass password creation). Is there a
    recognised way of populating multiple records' password fields with
    random passwords (say 8 characters long)?
    >
    A couple of possible complications.. .
    >
    1. The client wants to be able to insert the rest of the exhibitor
    data via a CSV upload (I'm using a Dreamweaver extension for this -
    http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
    creating individual records manually via the registration site.
    >
    2. They've also asked that the password avoids letter 'O' and numner
    '0'.
    >
    Thanks in advance!
    >
    No standard way, but lots of different ways to generate passwords. Try
    googling for

    "password generator" php

    You'll get lots of ideas.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • C. (http://symcbean.blogspot.com/)

      #3
      Re: Create passwords for multiple records (PHP/mySQL)

      On 25 Sep, 13:27, wozza <warren...@goog lemail.comwrote :
      hi
      >
      I'm a Dreamweaver user who's created a few simple data entry/
      registrations forms in my time, but I'm not really a coder (though I
      can follow instructions and am not afraid to dabble...) - I generally
      make use of DW's builtin commands and some extensions.
      >
      Anyway I'm creating a registration site for event exhibitors and I've
      been asked to come up with a method of automatically generating
      passwords for inserted records, either as they're inserted or at some
      point later (i.e. some kind of mass password creation). Is there a
      recognised way of populating multiple records' password fields with
      random passwords (say 8 characters long)?
      >
      A couple of possible complications.. .
      >
      1. The client wants to be able to insert the rest of the exhibitor
      data via a CSV upload (I'm using a Dreamweaver extension for this -http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
      creating individual records manually via the registration site.
      >
      2. They've also asked that the password avoids letter 'O' and numner
      '0'.
      >
      Thanks in advance!
      So you want to generate random passwords without the letter 0/number 0

      A simple solution would be to generate a hash of the data along with a
      secret salt - say

      $password=str_r eplace('0', 'g', substr(sha1($da ta . 's3cr3t'),
      0,8)); // sha1 is hex encoded i.e. 0-9,a-f

      Or if you want a more random solution with more emphasis on
      letters....

      $chars=explode( ',',"a,b,c,d,e, f,g,h,i,j,k,m,n ,p,q,r,t,u,x,y, z,
      2,3,4,5,6,7,8,9 ,!,$,%,&,*,@,#" ); // for niceness I've also omitted l
      (L) and 1 (one)
      shuffle($chars) ;
      $password=subst r($chars,0,8);

      C.

      Comment

      • Geoff Berrow

        #4
        Re: Create passwords for multiple records (PHP/mySQL)

        Message-ID:
        <3ad817e6-380a-4d9e-8abb-4af2dbfa6136@l4 3g2000hsh.googl egroups.comfrom
        wozza contained the following:
        >Anyway I'm creating a registration site for event exhibitors and I've
        >been asked to come up with a method of automatically generating
        >passwords for inserted records, either as they're inserted or at some
        >point later (i.e. some kind of mass password creation). Is there a
        >recognised way of populating multiple records' password fields with
        >random passwords (say 8 characters long)?
        >
        >A couple of possible complications.. .
        >
        >1. The client wants to be able to insert the rest of the exhibitor
        >data via a CSV upload (I'm using a Dreamweaver extension for this -
        >http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
        >creating individual records manually via the registration site.
        >
        >2. They've also asked that the password avoids letter 'O' and numner
        >'0'.
        >

        What you are asking is not a major task for a coder and that's the
        problem with DW generated code isn't it? You are fine until you want
        something a bit different. In this case you may be better off paying
        for an hour or so of a coder's time.

        For the passwords, there are any number of scripts you could use. I
        like to use a randomly chosen keyword (taken from a pool that I create
        to suit the website) plus a randomly generated number between 0001 and
        9999. This is reasonably secure as well as being fairly human friendly.
        It's a good idea to make sure the username is unique, that way the
        password need not be.


        Here's the function I use, here with words which suit a financial theme
        <?php
        function passgen(){
        $words=array("b usiness","entre preneur","econo my","bank","fin ance","money"," shares","incuba te","credit","i nvoice","direct or","efficient" ,"workplace","o ffice",
        "sales","projec tion");
        $key=array_rand ($words);
        $num=rand(1,999 9);
        $password=$word s[$key].$num;
        return $password;
        }

        echo passgen();

        ?>

        See http://4theweb.co.uk/test/test.php
        --
        Geoff Berrow 011000100110110 0010000000110
        001101101011011 001000110111101 100111001011
        100110001101101 111001011100111 010101101011
        http://slipperyhill.co.uk - http://4theweb.co.uk

        Comment

        • r0g

          #5
          Re: Create passwords for multiple records (PHP/mySQL)

          wozza wrote:
          hi
          >
          I'm a Dreamweaver user who's created a few simple data entry/
          registrations forms in my time, but I'm not really a coder (though I
          can follow instructions and am not afraid to dabble...) - I generally
          make use of DW's builtin commands and some extensions.
          >
          Anyway I'm creating a registration site for event exhibitors and I've
          been asked to come up with a method of automatically generating
          passwords for inserted records, either as they're inserted or at some
          point later (i.e. some kind of mass password creation). Is there a
          recognised way of populating multiple records' password fields with
          random passwords (say 8 characters long)?
          >
          A couple of possible complications.. .
          >
          1. The client wants to be able to insert the rest of the exhibitor
          data via a CSV upload (I'm using a Dreamweaver extension for this -
          http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
          creating individual records manually via the registration site.
          >
          2. They've also asked that the password avoids letter 'O' and numner
          '0'.
          >
          Thanks in advance!

          There's no standard way as it's pretty trivial to write a function to
          generate random strings. This is what I use...

          function rseq($x)
          {
          # Returns string of random alphanumeric characters of specified
          length $x
          # Note - mtrand (mersenne twister) used as rand not actually very
          random at all!
          $d = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ0123456 789";
          $dl = strlen($d)-1;
          $s = '';
          for($i = 0; $i < $x; $i++)
          {
          $s .= $d[(mt_rand(0,$dl) )];
          }
          return $s;
          }


          Just lose the O's and 0's from $d. Do also note that this uses mt_rand
          as PHP's normal random number generator is REALLY REALLY AWFUL.

          Not sure what you mean when you say 'insert the rest of the exhibitor
          data via a CSV upload'... What do they have and what do they want you to
          do with it?

          Regards,

          Roger.

          Comment

          • C. (http://symcbean.blogspot.com/)

            #6
            Re: Create passwords for multiple records (PHP/mySQL)

            On 25 Sep, 14:03, "C. (http://symcbean.blogsp ot.com/)"
            <colin.mckin... @gmail.comwrote :
            On 25 Sep, 13:27, wozza <warren...@goog lemail.comwrote :
            >
            >
            >
            hi
            >
            I'm a Dreamweaver user who's created a few simple data entry/
            registrations forms in my time, but I'm not really a coder (though I
            can follow instructions and am not afraid to dabble...) - I generally
            make use of DW's builtin commands and some extensions.
            >
            Anyway I'm creating a registration site for event exhibitors and I've
            been asked to come up with a method of automatically generating
            passwords for inserted records, either as they're inserted or at some
            point later (i.e. some kind of mass password creation). Is there a
            recognised way of populating multiple records' password fields with
            random passwords (say 8 characters long)?
            >
            A couple of possible complications.. .
            >
            1. The client wants to be able to insert the rest of the exhibitor
            data via a CSV upload (I'm using a Dreamweaver extension for this -http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
            creating individual records manually via the registration site.
            >
            2. They've also asked that the password avoids letter 'O' and numner
            '0'.
            >
            Thanks in advance!
            >
            So you want to generate random passwords without the letter 0/number 0
            >
            A simple solution would be to generate a hash of the data along with a
            secret salt - say
            >
            $password=str_r eplace('0', 'g', substr(sha1($da ta . 's3cr3t'),
            0,8)); // sha1 is hex encoded i.e. 0-9,a-f
            >
            Or if you want a more random solution with more emphasis on
            letters....
            >
            $chars=explode( ',',"a,b,c,d,e, f,g,h,i,j,k,m,n ,p,q,r,t,u,x,y, z,
            2,3,4,5,6,7,8,9 ,!,$,%,&,*,@,#" ); // for niceness I've also omitted l
            (L) and 1 (one)
            shuffle($chars) ;
            $password=subst r($chars,0,8);
            >
            C.
            Whoops - last line should be

            $password=subst r(implode('',$c hars),0,8);

            C.

            Comment

            • wozza

              #7
              Re: Create passwords for multiple records (PHP/mySQL)

              On 26 Sep, 07:01, r0g <aioe....@techn icalbloke.comwr ote:
              wozza wrote:
              hi
              >
              I'm a Dreamweaver user who's created a few simple data entry/
              registrations forms in my time, but I'm not really a coder (though I
              can follow instructions and am not afraid to dabble...) - I generally
              make use of DW's builtin commands and some extensions.
              >
              Anyway I'm creating a registration site for event exhibitors and I've
              been asked to come up with a method of automatically generating
              passwords for inserted records, either as they're inserted or at some
              point later (i.e. some kind of mass password creation). Is there a
              recognised way of populating multiple records' password fields with
              random passwords (say 8 characters long)?
              >
              A couple of possible complications.. .
              >
              1. The client wants to be able to insert the rest of the exhibitor
              data via a CSV upload (I'm using a Dreamweaver extension for this -
              http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
              creating individual records manually via the registration site.
              >
              2. They've also asked that the password avoids letter 'O' and numner
              '0'.
              >
              Thanks in advance!
              >
              There's no standard way as it's pretty trivial to write a function to
              generate random strings. This is what I use...
              >
                function rseq($x)
                  {
                    # Returns string of random alphanumeric characters of specified
              length $x
                    # Note - mtrand (mersenne twister) used as rand not actually very
              random at all!
                    $d = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ0123456 789";
                    $dl = strlen($d)-1;
                    $s = '';
                    for($i = 0; $i < $x; $i++)
                      {
                        $s .= $d[(mt_rand(0,$dl) )];
                      }
                    return $s;
                  }
              >
              Just lose the O's and 0's from $d. Do also note that this uses mt_rand
              as PHP's normal random number generator is REALLY REALLY AWFUL.
              >
              Not sure what you mean when you say 'insert the rest of the exhibitor
              data via a CSV upload'... What do they have and what do they want you to
              do with it?
              >
              Regards,
              >
              Roger.- Hide quoted text -
              >
              - Show quoted text -
              Thanks for the replies guys. I've now decided to go a differetn route
              in add the passwords to the records. Basically after inserting the
              contents of a CSV (via that 3rd party extension for Dreamweaver I
              mentioned) the browser is redirected to a php with the following
              code:

              <?php require_once('. ./Connections/connExhibiting. php'); ?>
              <?php
              mysql_select_db ($database_conn Exhibiting, $connExhibiting ) or
              die(mysql_error ());

              function genRandomString () {
              $length = 8;
              $characters = "123456789abcde fghijklmnpqrstu vwxyz";

              for ($p = 0; $p < $length; $p++) {
              $string .= $characters[mt_rand(0, strlen($charact ers))];
              }

              return $string;
              }

              $query = "SELECT ID, password FROM tblUsers";
              $result = mysql_query($qu ery) or die(mysql_error ());
              while($row = mysql_fetch_ass oc($result)) {
              $id = $row['ID'];
              $password = $row['password'];

              $genPassword = genRandomString ();

              $sql_update = "UPDATE tblUsers SET password = '$genPassword' WHERE
              (password = '' OR password is NULL)";
              mysql_query($sq l_update) or die(mysql_error ());
              }
              ?>
              <?php
              mysql_free_resu lt($result);
              ?>

              It _almost_ works, except the password is the same for all records - I
              need the string returned by genRandomString () to be different for each
              record - any help would be appreciated!

              Cheers

              Comment

              • wozza

                #8
                Re: Create passwords for multiple records (PHP/mySQL)

                On Sep 26, 7:01 am, r0g <aioe....@techn icalbloke.comwr ote:
                wozza wrote:
                hi
                >
                I'm a Dreamweaver user who's created a few simple data entry/
                registrations forms in my time, but I'm not really a coder (though I
                can follow instructions and am not afraid to dabble...) - I generally
                make use of DW's builtin commands and some extensions.
                >
                Anyway I'm creating a registration site for event exhibitors and I've
                been asked to come up with a method of automatically generating
                passwords for inserted records, either as they're inserted or at some
                point later (i.e. some kind of mass password creation). Is there a
                recognised way of populating multiple records' password fields with
                random passwords (say 8 characters long)?
                >
                A couple of possible complications.. .
                >
                1. The client wants to be able to insert the rest of the exhibitor
                data via a CSV upload (I'm using a Dreamweaver extension for this -
                http://www.felixone.it/extensions/prod/mxiecsven.asp) as well as
                creating individual records manually via the registration site.
                >
                2. They've also asked that the password avoids letter 'O' and numner
                '0'.
                >
                Thanks in advance!
                >
                There's no standard way as it's pretty trivial to write a function to
                generate random strings. This is what I use...
                >
                  function rseq($x)
                    {
                      # Returns string of random alphanumeric characters of specified
                length $x
                      # Note - mtrand (mersenne twister) used as rand not actually very
                random at all!
                      $d = "abcdefghijklmn opqrstuvwxyzABC DEFGHIJKLMNOPQR STUVWXYZ0123456 789";
                      $dl = strlen($d)-1;
                      $s = '';
                      for($i = 0; $i < $x; $i++)
                        {
                          $s .= $d[(mt_rand(0,$dl) )];
                        }
                      return $s;
                    }
                >
                Just lose the O's and 0's from $d. Do also note that this uses mt_rand
                as PHP's normal random number generator is REALLY REALLY AWFUL.
                >
                Not sure what you mean when you say 'insert the rest of the exhibitor
                data via a CSV upload'... What do they have and what do they want you to
                do with it?
                >
                Regards,
                >
                Roger.- Hide quoted text -
                >
                - Show quoted text -
                Thanks for the replies guys. I've now decided to go a differetn route
                in add the passwords to the records. Basically after inserting the
                contents of a CSV (via that 3rd party extension for Dreamweaver I
                mentioned) the browser is redirected to a php with the following
                code:

                <?php require_once('. ./Connections/connExhibiting. php'); ?>
                <?php
                mysql_select_db ($database_conn Exhibiting, $connExhibiting ) or
                die(mysql_error ());


                function genRandomString () {
                $length = 8;
                $characters = "123456789abcde fghijklmnpqrstu vwxyz";


                for ($p = 0; $p < $length; $p++) {
                $string .= $characters[mt_rand(0, strlen($charact ers))];
                }


                return $string;



                }


                $query = "SELECT ID, password FROM tblUsers";
                $result = mysql_query($qu ery) or die(mysql_error ());
                while($row = mysql_fetch_ass oc($result)) {

                $genPassword = genRandomString ();

                $sql_update = "UPDATE tblUsers SET password = '$genPassword'
                WHERE
                (password = '' OR password is NULL)";
                mysql_query($sq l_update) or die(mysql_error ());
                }
                ?>
                <?php
                mysql_free_resu lt($result);
                ?>


                It _almost_ works, except the password is the same for all records -
                I
                need the string returned by genRandomString () to be different for
                each
                record - any help would be appreciated!


                Cheers

                Comment

                Working...