MySQLPHP decrypt(password)

MySQLPHP decrypt(password)

am 25.02.2005 11:20:55 von moses Woldeselassie

hi all

I am using password() to crypt a user password online. but how do i decrypt
a user password, when user forgot his/her password?


kind regards
m

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: MySQLPHP decrypt(password)

am 25.02.2005 20:03:14 von Martin.Norland

moses Woldeselassie wrote:
> hi all
>
> I am using password() to crypt a user password online. but how do i
> decrypt a user password, when user forgot his/her password?
>
>
> kind regards
> m

You don't - that's the point. You have to provide them with a way to
reset their password, based on some other method of authentication.
Traditionally this is done with mailing a user a password reset link,
and having that link only available for a short period of time.

Cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International
Outreach x3257
The opinion(s) contained within this email do not necessarily represent
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: MySQLPHP decrypt(password)

am 25.02.2005 20:04:30 von Bastien Koert

You can't. Its an MD5 hash, not an encryption...I reset the password to a
random one, and email it to the user, also flag the account to force them to
change the password upon login...

[code]
function mail_password()
{
global $err_msg;
//get the variables from the form
if ((isset($_POST['email']))&&(isset($_POST['lg_name']))){
$email = $_POST['email'];
$mid = $_POST['lg_name'];
$date_cookie = $_COOKIE['last_time'];
}else{
$err_msg = "Please enter both your email address and your username.
Thank you.
";
show_form();
die();
}//end if

//create the sql and run the query
$sql = "SELECT * FROM users WHERE user_email='$email' and user_name =
'$mid'";

$result = connect($sql);

//check the query results
if (mysql_num_rows($result)!=1){
$err_msg = "No results found. Please re-enter your
username and email address to try again.
";
show_form();

}else{

$row = mysql_fetch_array($result);
$email2 = $row['cust_email'];
$pass = $row['cust_pw'];

//call the change password function and pass it the information related to
the record to create the temp password
$new_pass = change_password($mid, $pass);

$sendto = $email2;
$from = "WebMaster ";
$subject = "Forgotten Password";
$message = "Dear $email2,

Your password is $new_pass.

Regards,
Webmaster";
echo $message;

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"".$from."\" <".$from.">\n";

if (!mail($sendto, $subject, $message, $headers)){
echo "Mail failed to send";
}else{
header("location:confirm1.htm");
}//end if
}//end if
}//end function

//---------------------------------------------------------- -----------------------------
// change password function
//---------------------------------------------------------- -----------------------------
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
[/code]


bastien



>From: "moses Woldeselassie"
>To: php-db@lists.php.net
>Subject: [PHP-DB] MySQLPHP decrypt(password)
>Date: Fri, 25 Feb 2005 10:20:55 +0000
>
>hi all
>
>I am using password() to crypt a user password online. but how do i decrypt
>a user password, when user forgot his/her password?
>
>
>kind regards
>m
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: MySQLPHP decrypt(password)

am 25.02.2005 22:59:47 von Robby Russell

On Fri, 2005-02-25 at 10:20 +0000, moses Woldeselassie wrote:
>hi all
>
>I am using password() to crypt a user password online. but how do i decrypt
>a user password, when user forgot his/her password?
>
>
>kind regards
>m
>

You don't. You make them reset their password.

-Robby


--
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON | www.planetargon.com
* Portland, OR | robby@planetargon.com
* 503.351.4730 | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
* --- Now hosting Ruby on Rails Apps ---
****************************************/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: MySQLPHP decrypt(password)

am 28.02.2005 12:16:23 von moses Woldeselassie

Thank you Bastien

It works fine, but i do have a problem with login. MySQL does not allowed
the user to login.


I did try to use sending email without using the change_password(), but it
is sending different password each time:

1. Why is it sending different password for one user?
2. How could I get a user password without changing a user password?




kind regards
m






>From: "Bastien Koert" <bastien_k@hotmail.com>
>To: mmoses@hotmail.com, php-db@lists.php.net
>Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
>Date: Fri, 25 Feb 2005 14:04:30 -0500
>
>You can't. Its an MD5 hash, not an encryption...I reset the password to
a random one, and email it to the user, also flag the account to force them
to change the password upon login...
>
>[code]
>function mail_password()
>{
> global $err_msg;
> //get the variables from the form
> if ((isset($_POST['email']))&&(isset($_POST['lg_name']) )){
> $email = $_POST['email'];
> $mid = $_POST['lg_name'];
> $date_cookie = $_COOKIE['last_time'];
> }else{
> $err_msg = "<b>Please enter both your email address and
your username. Thank you.</b>";
> show_form();
> die();
> }//end if
>
> //create the sql and run the query
> $sql = "SELECT * FROM users WHERE user_email='$email' and
user_name = '$mid'";
>
> $result = connect($sql);
>
> //check the query results
> if (mysql_num_rows($result)!=1){
> $err_msg = "<font color=red>No results found. Please
re-enter your username and email address to try again.</font>";
> show_form();
>
> }else{
>
> $row = mysql_fetch_array($result);
> $email2 = $row['cust_email'];
> $pass = $row['cust_pw'];
>
> //call the change password function and pass it the information
related to the record to create the temp password
> $new_pass = change_password($mid, $pass);
>
> $sendto = $email2;
> $from = "WebMaster <webmaster@doctorchoicellc.com>";
> $subject = "Forgotten Password";
> $message = "Dear $email2,
>
> Your password is $new_pass.
>
> Regards,
> Webmaster";
> echo $message;
>
> $headers = "MIME-Version: 1.0\n";
> $headers .= "Content-type: text/plain;
charset=iso-8859-1\n";
> $headers .= "X-Priority: 3\n";
> $headers .= "X-MSMail-Priority: Normal\n";
> $headers .= "X-Mailer: php\n";
> $headers .= "From: \"".$from."\"
<".$from.">\n";
>
> if (!mail($sendto, $subject, $message, $headers)){
> echo "Mail failed to send";
> }else{
> header("location:confirm1.htm");
> }//end if
> }//end if
>}//end function
>
> //---------------------------------------------------------- -----------------------------
>// change password function
> //---------------------------------------------------------- -----------------------------
>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
>[/code]
>
>
>bastien
>
>
>
> >From: "moses Woldeselassie" <mmoses@hotmail.com>
> >To: php-db@lists.php.net
> >Subject: [PHP-DB] MySQLPHP decrypt(password)
> >Date: Fri, 25 Feb 2005 10:20:55 +0000
> >
> >hi all
> >
> >I am using password() to crypt a user password online. but how do i
decrypt a user password, when user forgot his/her password?
> >
> >
> >kind regards
> >m
> >
> >--
> >PHP Database Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
> >
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: MySQLPHP decrypt(password)

am 28.02.2005 17:52:42 von moses Woldeselassie

thank you.

I do have login and registration script, which work fine. the problem is
with new password.

I am using password() to registrate a user. I did change in the
change_password()
md5() into password(), it changes the user password. I coud easliy see it in
mysql db.

but a user could not login using the new password.
do i have to change the password() into md5() in the registration php
script?

1. is it anyway i could get the password without changing a user password
from mysql.

kind regards
m

>From: "Bastien Koert" <bastien_k@hotmail.com>
>To: mmoses@hotmail.com
>Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
>Date: Mon, 28 Feb 2005 09:31:20 -0500
>
>There needs to be a separate login page...The previous page was simply
to change the password...
>
>here is my login function...
>
> //---------------------------------------------------------- -----------------------------
>// login function
> //---------------------------------------------------------- -----------------------------
>function login()
>{
> global $err_msg;
> $errors = array();
>
> if ((empty
($_POST['lg_name']))&&(!eregi("[[:alnum:]]",$_POST['lg_name']))){
> $errors[] = "<font color=red>You didn't enter a correct
login name.</font>";}
> if ((empty
($_POST['lg_pw']))&&(!eregi("[[:alnum:]]",$_POST['lg_pw']))){
> $errors[] = "<font color=red>You didn't enter a
password.</font>";}
>
> if (count($errors) > 0) {
>
> for ($i = 0; $i < $nerrors; $i++){
> $err_msg .= $errors[$i]."<br />";
> }
> show_form();
> exit();
> }//end if
>
> $lg_name = $_POST['lg_name'];
> $lg_pw = $_POST['lg_pw'];
>
> $new_select = "select cust_lg, cust_pw, temp_pass from cust_info
where cust_lg = '$lg_name' and cust_pw = '$lg_pw'";
> $result = connect($new_select);
> $num_result = mysql_num_rows ($result);
>
> if ($num_result == 1) {
>
> //if the temp_password value is set to 1 then have the user change the
password.
> $row = mysql_fetch_array($result);
> if ($row['temp_pass']==1){
> header("location:change_pass.php");
> die();
> }//end if
>
> setcookie('last_time',
date("Ymd-his"),time()+60*60*24*30,'/');
> echo "here";
> header("location:/login_unit/brokerpanel.htm");
> exit();
> }else{
> $err_msg = "<font color=red>No match found! If you have
forgotten your password, please click the link at the right.</font";
> show_form();
> exit();
> }
>}//end functon
>
>?>
>
>bastien
>
> >From: "moses Woldeselassie" <mmoses@hotmail.com>
> >To: bastien_k@hotmail.com, php-db@lists.php.net
> >Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
> >Date: Mon, 28 Feb 2005 11:16:23 +0000
> >
> >Thank you Bastien
> >
> >It works fine, but i do have a problem with login. MySQL does not
allowed the user to login.
> >
> >
> >I did try to use sending email without using the change_password(),
but it is sending different password each time:
> >
> >1. Why is it sending different password for one user?
> >2. How could I get a user password without changing a user
password?
> >
> >
> >
> >
> >kind regards
> >m
> >
> >
> >
> >
> >
> >
> >&gt;From: &quot;Bastien Koert&quot;
&lt;bastien_k@hotmail.com&gt;
> >&gt;To: mmoses@hotmail.com, php-db@lists.php.net
> >&gt;Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
> >&gt;Date: Fri, 25 Feb 2005 14:04:30 -0500
> >&gt;
> >&gt;You can't. Its an MD5 hash, not an encryption...I reset the
password to a random one, and email it to the user, also flag the account to
force them to change the password upon login...
> >&gt;
> >&gt;[code]
> >&gt;function mail_password()
> >&gt;{
> >&gt; global $err_msg;
> >&gt; //get the variables from the form
> >&gt; if
((isset($_POST['email']))&amp;&amp;(isset($_POST['lg _name']))){
> >&gt; $email = $_POST['email'];
> >&gt; $mid = $_POST['lg_name'];
> >&gt; $date_cookie = $_COOKIE['last_time'];
> >&gt; }else{
> >&gt; $err_msg = &quot;&lt;b&gt;Please enter both
your email address and your username. Thank
you.&lt;/b&gt;&quot;;
> >&gt; show_form();
> >&gt; die();
> >&gt; }//end if
> >&gt;
> >&gt; //create the sql and run the query
> >&gt; $sql = &quot;SELECT * FROM users WHERE
user_email='$email' and user_name = '$mid'&quot;;
> >&gt;
> >&gt; $result = connect($sql);
> >&gt;
> >&gt; //check the query results
> >&gt; if (mysql_num_rows($result)!=1){
> >&gt; $err_msg = &quot;&lt;font color=red&gt;No
results found. Please re-enter your username and email address to try
again.&lt;/font&gt;&quot;;
> >&gt; show_form();
> >&gt;
> >&gt; }else{
> >&gt;
> >&gt; $row = mysql_fetch_array($result);
> >&gt; $email2 = $row['cust_email'];
> >&gt; $pass = $row['cust_pw'];
> >&gt;
> >&gt; //call the change password function and pass it the
information related to the record to create the temp password
> >&gt; $new_pass = change_password($mid, $pass);
> >&gt;
> >&gt; $sendto = $email2;
> >&gt; $from = &quot;WebMaster
&lt;webmaster@doctorchoicellc.com&gt;&quot;;
> >&gt; $subject = &quot;Forgotten Password&quot;;
> >&gt; $message = &quot;Dear $email2,
> >&gt;
> >&gt; Your password is $new_pass.
> >&gt;
> >&gt; Regards,
> >&gt; Webmaster&quot;;
> >&gt; echo $message;
> >&gt;
> >&gt; $headers = &quot;MIME-Version: 1.0\n&quot;;
> >&gt; $headers .= &quot;Content-type: text/plain;
charset=iso-8859-1\n&quot;;
> >&gt; $headers .= &quot;X-Priority: 3\n&quot;;
> >&gt; $headers .= &quot;X-MSMail-Priority:
Normal\n&quot;;
> >&gt; $headers .= &quot;X-Mailer: php\n&quot;;
> >&gt; $headers .= &quot;From:
\&quot;&quot;.$from.&quot;\&quot;
&lt;&quot;.$from.&quot;&gt;\n&quot;;
> >&gt;
> >&gt; if (!mail($sendto, $subject, $message, $headers)){
> >&gt; echo &quot;Mail failed to send&quot;;
> >&gt; }else{
> >&gt; header(&quot;location:confirm1.htm&quot;);
> >&gt; }//end if
> >&gt; }//end if
> >&gt;}//end function
> >&gt;
>
> &gt;//-------------------------------------------------- -------------------------------------
> >&gt;// change password function
>
> &gt;//-------------------------------------------------- -------------------------------------
> >&gt;function change_password($id, $password)
> >&gt;{
> >&gt; //generate a random password
> >&gt; $pass = &quot;&quot;;
> >&gt; $salt =
&quot;abchefghjkmnpqrstuvwxyz0123456789&quot;;
> >&gt; srand((double)microtime()*1000000);
> >&gt; $i = 0;
> >&gt; while ($i &lt;= 7) {
> >&gt; $num = rand() % 33;
> >&gt; $tmp = substr($salt, $num, 1);
> >&gt; $pass = $pass . $tmp;
> >&gt; $i++;
> >&gt; }
> >&gt; //change the password in the db
> >&gt; $sql = &quot;update cust_info set
cust_pw ='&quot;.md5($pass).&quot;', temp_pass = 1 where cust_lg =
'$id' and cust_pw = '$password'&quot;;
> >&gt; $result = connect($sql);
> >&gt; if ($result){
> >&gt; return $pass;
> >&gt; }else{
> >&gt; change_password($id, $password);
> >&gt; }
> >&gt;}//end function
> >&gt;[/code]
> >&gt;
> >&gt;
> >&gt;bastien
> >&gt;
> >&gt;
> >&gt;
> >&gt; &gt;From: &quot;moses Woldeselassie&quot;
&lt;mmoses@hotmail.com&gt;
> >&gt; &gt;To: php-db@lists.php.net
> >&gt; &gt;Subject: [PHP-DB] MySQLPHP decrypt(password)
> >&gt; &gt;Date: Fri, 25 Feb 2005 10:20:55 +0000
> >&gt; &gt;
> >&gt; &gt;hi all
> >&gt; &gt;
> >&gt; &gt;I am using password() to crypt a user password
online. but how do i decrypt a user password, when user forgot his/her
password?
> >&gt; &gt;
> >&gt; &gt;
> >&gt; &gt;kind regards
> >&gt; &gt;m
> >&gt; &gt;
> >&gt; &gt;--
> >&gt; &gt;PHP Database Mailing List (http://www.php.net/)
> >&gt; &gt;To unsubscribe, visit:
http://www.php.net/unsub.php
> >&gt; &gt;
> >&gt;
> >
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

RE: MySQLPHP decrypt(password)

am 28.02.2005 18:06:41 von Bastien Koert

Password and MD$ return different values. They are not compatible. Since
both are one way encryptions, you can not retrive the orginal value


>From: "moses Woldeselassie"
>To: bastien_k@hotmail.com, php-db@lists.php.net
>Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
>Date: Mon, 28 Feb 2005 16:44:56 +0000
>
>
>thank you Bastien
>
>I do have a login and registration php sript, which work fine. the problem
>is I am using password(passwd) to registrat the user, and i did change md5
>into password() but how do i get the password that a user has registrated
>in the first time?
>
>
>
>other problem:
>
>i did try to use the sending email using the following:
>
>select passwd from users where username=$mid and email = $email
>
>but it doesn't work. If i put * instead of passwd it works fine.
>select * from users where username=$mid and email=$email
>
>what is the problem?
>
>I didn't get it, a user should easliy login using the new password, which
>was changed using change_password().
>
>
>
>kind regards
>m
>
>
>
>
>>From: "Bastien Koert" <bastien_k@hotmail.com>
>>To: mmoses@hotmail.com
>>Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
>>Date: Mon, 28 Feb 2005 09:31:20 -0500
>>
>>There needs to be a separate login page...The previous page was simply
>to change the password...
>>
>>here is my login function...
>>
>> //---------------------------------------------------------- -----------------------------
>>// login function
>> //---------------------------------------------------------- -----------------------------
>>function login()
>>{
>> global $err_msg;
>> $errors = array();
>>
>> if ((empty
>($_POST['lg_name']))&&(!eregi("[[:alnum:]]",$_POST['lg_name']))){
>> $errors[] = "<font color=red>You didn't enter a correct
>login name.</font>";}
>> if ((empty
>($_POST['lg_pw']))&&(!eregi("[[:alnum:]]",$_POST['lg_pw']))){
>> $errors[] = "<font color=red>You didn't enter a
>password.</font>";}
>>
>> if (count($errors) > 0) {
>>
>> for ($i = 0; $i < $nerrors; $i++){
>> $err_msg .= $errors[$i]."<br />";
>> }
>> show_form();
>> exit();
>> }//end if
>>
>> $lg_name = $_POST['lg_name'];
>> $lg_pw = $_POST['lg_pw'];
>>
>> $new_select = "select cust_lg, cust_pw, temp_pass from cust_info
>where cust_lg = '$lg_name' and cust_pw = '$lg_pw'";
>> $result = connect($new_select);
>> $num_result = mysql_num_rows ($result);
>>
>> if ($num_result == 1) {
>>
>> //if the temp_password value is set to 1 then have the user change
>the password.
>> $row = mysql_fetch_array($result);
>> if ($row['temp_pass']==1){
>> header("location:change_pass.php");
>> die();
>> }//end if
>>
>> setcookie('last_time',
>date("Ymd-his"),time()+60*60*24*30,'/');
>> echo "here";
>> header("location:/login_unit/brokerpanel.htm");
>> exit();
>> }else{
>> $err_msg = "<font color=red>No match found! If you have
>forgotten your password, please click the link at the
>right.</font";
>> show_form();
>> exit();
>> }
>>}//end functon
>>
>>?>
>>
>>bastien
>>
>> >From: "moses Woldeselassie" <mmoses@hotmail.com>
>> >To: bastien_k@hotmail.com, php-db@lists.php.net
>> >Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
>> >Date: Mon, 28 Feb 2005 11:16:23 +0000
>> >
>> >Thank you Bastien
>> >
>> >It works fine, but i do have a problem with login. MySQL does not
>allowed the user to login.
>> >
>> >
>> >I did try to use sending email without using the
>change_password(), but it is sending different password each time:
>> >
>> >1. Why is it sending different password for one user?
>> >2. How could I get a user password without changing a user
>password?
>> >
>> >
>> >
>> >
>> >kind regards
>> >m
>> >
>> >
>> >
>> >
>> >
>> >
>> >&gt;From: &quot;Bastien Koert&quot;
>&lt;bastien_k@hotmail.com&gt;
>> >&gt;To: mmoses@hotmail.com, php-db@lists.php.net
>> >&gt;Subject: RE: [PHP-DB] MySQLPHP decrypt(password)
>> >&gt;Date: Fri, 25 Feb 2005 14:04:30 -0500
>> >&gt;
>> >&gt;You can't. Its an MD5 hash, not an encryption...I reset
>the password to a random one, and email it to the user, also flag the
>account to force them to change the password upon login...
>> >&gt;
>> >&gt;[code]
>> >&gt;function mail_password()
>> >&gt;{
>> >&gt; global $err_msg;
>> >&gt; //get the variables from the form
>> >&gt; if
>((isset($_POST['email']))&amp;&amp;(isset($_POST['l g_name']))){
>> >&gt; $email = $_POST['email'];
>> >&gt; $mid = $_POST['lg_name'];
>> >&gt; $date_cookie = $_COOKIE['last_time'];
>> >&gt; }else{
>> >&gt; $err_msg = &quot;&lt;b&gt;Please enter both
>your email address and your username. Thank
>you.&lt;/b&gt;&quot;;
>> >&gt; show_form();
>> >&gt; die();
>> >&gt; }//end if
>> >&gt;
>> >&gt; //create the sql and run the query
>> >&gt; $sql = &quot;SELECT * FROM users WHERE
>user_email='$email' and user_name = '$mid'&quot;;
>> >&gt;
>> >&gt; $result = connect($sql);
>> >&gt;
>> >&gt; //check the query results
>> >&gt; if (mysql_num_rows($result)!=1){
>> >&gt; $err_msg = &quot;&lt;font color=red&gt;No
>results found. Please re-enter your username and email address to try
>again.&lt;/font&gt;&quot;;
>> >&gt; show_form();
>> >&gt;
>> >&gt; }else{
>> >&gt;
>> >&gt; $row = mysql_fetch_array($result);
>> >&gt; $email2 = $row['cust_email'];
>> >&gt; $pass = $row['cust_pw'];
>> >&gt;
>> >&gt; //call the change password function and pass it the
>information related to the record to create the temp password
>> >&gt; $new_pass = change_password($mid, $pass);
>> >&gt;
>> >&gt; $sendto = $email2;
>> >&gt; $from = &quot;WebMaster
>&lt;webmaster@doctorchoicellc.com&gt;&quot;;
>> >&gt; $subject = &quot;Forgotten Password&quot;;
>> >&gt; $message = &quot;Dear $email2,
>> >&gt;
>> >&gt; Your password is $new_pass.
>> >&gt;
>> >&gt; Regards,
>> >&gt; Webmaster&quot;;
>> >&gt; echo $message;
>> >&gt;
>> >&gt; $headers = &quot;MIME-Version: 1.0\n&quot;;
>> >&gt; $headers .= &quot;Content-type: text/plain;
>charset=iso-8859-1\n&quot;;
>> >&gt; $headers .= &quot;X-Priority: 3\n&quot;;
>> >&gt; $headers .= &quot;X-MSMail-Priority:
>Normal\n&quot;;
>> >&gt; $headers .= &quot;X-Mailer: php\n&quot;;
>> >&gt; $headers .= &quot;From:
>\&quot;&quot;.$from.&quot;\&quot;
>&lt;&quot;.$from.&quot;&gt;\n&quot;;
>> >&gt;
>> >&gt; if (!mail($sendto, $subject, $message, $headers)){
>> >&gt; echo &quot;Mail failed to send&quot;;
>> >&gt; }else{
>> >&gt; header(&quot;location:confirm1.htm&quot;);
>> >&gt; }//end if
>> >&gt; }//end if
>> >&gt;}//end function
>> >&gt;
>>
>> &gt;//-------------------------------------------------- -------------------------------------
>> >&gt;// change password function
>>
>> &gt;//-------------------------------------------------- -------------------------------------
>> >&gt;function change_password($id, $password)
>> >&gt;{
>> >&gt; //generate a random password
>> >&gt; $pass = &quot;&quot;;
>> >&gt; $salt =
>&quot;abchefghjkmnpqrstuvwxyz0123456789&quot;;
>> >&gt; srand((double)microtime()*1000000);
>> >&gt; $i = 0;
>> >&gt; while ($i &lt;= 7) {
>> >&gt; $num = rand() % 33;
>> >&gt; $tmp = substr($salt, $num, 1);
>> >&gt; $pass = $pass . $tmp;
>> >&gt; $i++;
>> >&gt; }
>> >&gt; //change the password in the db
>> >&gt; $sql = &quot;update cust_info set
>cust_pw ='&quot;.md5($pass).&quot;', temp_pass = 1 where cust_lg =
>'$id' and cust_pw = '$password'&quot;;
>> >&gt; $result = connect($sql);
>> >&gt; if ($result){
>> >&gt; return $pass;
>> >&gt; }else{
>> >&gt; change_password($id, $password);
>> >&gt; }
>> >&gt;}//end function
>> >&gt;[/code]
>> >&gt;
>> >&gt;
>> >&gt;bastien
>> >&gt;
>> >&gt;
>> >&gt;
>> >&gt; &gt;From: &quot;moses Woldeselassie&quot;
>&lt;mmoses@hotmail.com&gt;
>> >&gt; &gt;To: php-db@lists.php.net
>> >&gt; &gt;Subject: [PHP-DB] MySQLPHP decrypt(password)
>> >&gt; &gt;Date: Fri, 25 Feb 2005 10:20:55 +0000
>> >&gt; &gt;
>> >&gt; &gt;hi all
>> >&gt; &gt;
>> >&gt; &gt;I am using password() to crypt a user password
>online. but how do i decrypt a user password, when user forgot his/her
>password?
>> >&gt; &gt;
>> >&gt; &gt;
>> >&gt; &gt;kind regards
>> >&gt; &gt;m
>> >&gt; &gt;
>> >&gt; &gt;--
>> >&gt; &gt;PHP Database Mailing List (http://www.php.net/)
>> >&gt; &gt;To unsubscribe, visit:
>http://www.php.net/unsub.php
>> >&gt; &gt;
>> >&gt;
>> >
>>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php