I have a recovery help page where the user submits his/her email and then is sent the password. The problem that I am having is that the password is MD5 encrypted. Can someone help me with this code so that the password is sent to the user?
[php]<?php
if(ereg("memberforgotpassword.php",$_SERVER['PHP_SELF'])){
@header("Location:index.php");
die("<script>window.location='index.php';</script>"); //js redirect backup
}
//if post => process form
if(isset($_POST['email']) && $_POST['email'] != ""){
$sql = sprintf("select email, password from members where email = '%s' ", mysql_real_escape_string($_POST['email'], $mysql->conn));
$result = $mysql->exSql($sql) or die($mysql->debugPrint());
if(mysql_num_rows($result)>0){
$row = mysql_fetch_assoc($result);
//Validate that admin email & member's email are valid
if(validEmail($row['email']) && validEmail($settings['email'])){
//send message
$to = $row['email'];
$headers = sprintf("From: %s\r\nReply-To: noreply@%s\r\nX-Mailer: PHP/%s", $settings['email'], str_replace("www.","",str_replace("http://","",$settings['domain'])), phpversion());
$emailXtpl = new XTemplate("emailmessages/forgotpassword.xtpl", SKIN);
$emailXtpl->assign('row',$row);
$emailXtpl->assign('settings',$settings);
$emailXtpl->parse('main.subject');
$emailXtpl->parse('main.body');
$subject = $emailXtpl->text('main.subject');
$message = $emailXtpl->text('main.body');
if(@mail($to,$subject,$message,$headers)){
$xtpl->parse('main.passwordsent');
}else{
$xtpl->assign('error','Please contact webmaster [Failed to send message]');
$xtpl->parse('main.forgotpassword.error');
$xtpl->parse('main.forgotpassword');
}
}else{
$xtpl->assign('error','Please contact webmaster [Invalid Email(s)]');
$xtpl->parse('main.forgotpassword.error');
$xtpl->parse('main.forgotpassword');
}
}else{
$xtpl->assign('error','Email address not found');
$xtpl->parse('main.forgotpassword.error');
$xtpl->parse('main.forgotpassword');
}
}else{
$xtpl->parse('main.forgotpassword');
}
?>[/php]