RE: [PHP-DB] Random Character String

From: Date: Sat, 05 Mar 2005 15:45:24 +0000
Subject: RE: [PHP-DB] Random Character String
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-38781@lists.php.net to get a copy of this message
i use this function to generate a random 7 letter password...simple change to make it 8 function change_password($id, $password) { //generate a random password $pass = ""; $salt = "abchefghjkmnpqrstuvwxyz0123456789"; srand((double)microtime()*1000000); $i = 0; while ($i <= 7) { $num = rand() % 33; $tmp = substr($salt, $num, 1); $pass = $pass . $tmp; $i++; } //change the password in the db $sql = "update cust_info set cust_pw ='".md5($pass)."', temp_pass = 1 where cust_lg = '$id' and cust_pw = '$password'"; $result = connect($sql); if ($result){ return $pass; }else{ change_password($id, $password); } }//end function SQL is case insensitive for most queries. but you can use UPPER or LOWER to force case to one or the other if you feel its a problem for the html tag http://www.robotstxt.org/wc/meta-user.html bastien
From: "Ron Piggott" <ron.php@actsministries.org> To: "PHP DB" <php-db@lists.php.net> Subject: [PHP-DB] Random Character String Date: Sat, 5 Mar 2005 09:38:35 -0500 Is there a way of generating an 8 character random string in PHP? Is there a way to ignore UPPER and lower case when you are using the SELECT command to find a record in the mySQL table? I know this isn't an HTML forum ... I have one more question which is more HTML in nature. I don't want some of the web pages to be indexed that my PHP scripts are creating. Is there a tag you know of to prevent this from happening? Ron -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.db (#38781) next »