Posted 25 February 2003 - 04:12 AM
I am trying to insert random usernames and passwords into my database.
When i just use rand() it generates a number the length of the field between 0 and 1. my fields are set to 15 chars so i end up with something like \"0.1789632597412\". Are there arguments that go with this function that would let me generate a 10 char string made up of random letters and numbers like \"ad4er888af\"? Thanks
Posted 28 February 2003 - 09:38 AM
(i.e. chop off the 0. from the beginning of strand, and keep 15 characters...)
Otherwise you\'ll have to make a small function that\'ll return a number of random characters and call that... It\'ll require 15 calls to the rand function...
Maybe you _could_ do a trick by encoding the random number to a password by using crypt($string) - I\'m not absolutely sure what it returns - maybe just numbers as well... try it...
Posted 01 March 2003 - 01:35 AM
$unique = microtime();
$randstr = md5($unique);
$randstr = substr(\"$randstr\", 0,10);
print \"\".$randstr.\"<br />\";
$randpass = md5($randstr);
$randpass = substr(\"$randpass\", 0,10);
<?php str_replace("ASP", "PHP", $str); ?>
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users