/home/mip/public_html_/old-website/forgotpassword.php
<?
require_once("func_proc.php");
do_header("Forgot your password");
?>
<table width="585" border="0" cellpadding="0" cellspacing="0">
<tr><td width="585" align="right" valign="top">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" background="images/iris_main_bgleft.gif" style="background-repeat:no-repeat">
<tr><td width="585" height="170" valign="top" style="padding-left:25px; padding-right:20px; padding-top:15px"><p align="left"><span class="style3">FORGOT</span><span class="style5"> YOUR PASSWORD</span></p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td>
<form action="<?=$PHP_SELF?>" method="post" name="thisonly">
<table border="0" cellpadding="3" cellspacing="0" width="100%">
<tr>
<td colspan="2">Use the form below to have your password reset and your account details mailed back to you.</td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td width="25%"><b>Registered email:</b></td>
<td>
<input type="text" name="email" value="<?=$email?>" size="30" />
<input type="submit" name="submit" value=" Submit " />
</td>
</tr>
</table>
</form>
</td></tr>
</table>
</td></tr>
</table>
</td></tr>
</table>
<?
do_rightContent();
do_footer();
if($submit) {
if($email) {
$personal = getdata("select * from personal where 1 and email = '$email'");
$web_personal = getdata("select * from web_personal where 1 and email = '$email'");
if($personal || $web_personal) {
if($personal) $tablesave = 'personal';
if($web_personal) $tablesave = 'web_personal';
$company = getdata_one("*","company",1,1);
$fromhead = $company["agency_name"];
$from = $company["agency_email"];
$to = $email;
$subject = "You New Password";
$mynewpassword = substr(cmd_guid(),0,8);
$body = '
<html>
<head>
<title>You New Password</title>
</head>
<body>
<table>
<tr>
<td>Your Email:</td><td> '.$email.'</td>
</tr>
<tr>
<td>Your New Password:</td><td> '.$mynewpassword.'</td>
</tr>
</table>
</body>
</html>
';
/*
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'To:'.$to.'' . "\r\n";
$headers .= 'From: '.$fromhead.' <'.$from.'>' . "\r\n";
if(mail($to, $subject, $body, $headers)) {
$msg = "Your new password has been sent to your email. Please check your inbox.";
$db = db_connect();
$sql = "UPDATE $tablesave SET password='$mynewpassword' WHERE email = '$email'";
$result = mysql_query($sql,$db);
} else {
$msg = "Error Retrieving your password. Please Try Again";
}
*/
$smtphost=$smtphost;
$smtpusername=$smtpusername;
$smtpassword=$smtpassword;
$smtpport=$smtpport;
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = $smtphost; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = $smtpusername; // SMTP username
$mail->Password = $smtpassword; // SMTP password
$mail->FromName = $fromhead;
$mail->From = $from;
$emails = explode(";",$to);
for($xx = 0; $xx < count($emails); $xx++){
if($emails[$xx]) {
$mail->AddAddress($emails[$xx]);
}
}
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $subject;
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
$messagefinal = $body;
$mail->MsgHTML(stripslashes($messagefinal));
if($mail->Send()){ // if send
$msg = "Your new password has been sent to your email. Please check your inbox.";
$db = db_connect();
$sql = "UPDATE $tablesave SET password='$mynewpassword' WHERE email = '$email'";
$result = mysql_query($sql,$db);
} else {
$msg = "Error Retrieving your password. Please Try Again";
}
} else {
$msg = 'The email address '.$email.' was not found in the database.';
}
} else {
$msg = 'Please Enter Registered email';
}
}
if($msg) echo "<script>alert('$msg')</script>";
?>