<?php include("welcome.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Forgot Password</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="include/style.css" type="text/css" rel="stylesheet" />
</head>
<body topmargin="0">
<?php include("header.php"); ?>
<?php
if(isset($_POST["Submit"]))
{//see if this email address is on file with us
require_once('include/connections.php');
$colname_get_email = "1";
if (isset($HTTP_POST_VARS['email_address'])) {
$colname_get_email = (get_magic_quotes_gpc()) ? $HTTP_POST_VARS['email_address'] : addslashes($HTTP_POST_VARS['email_address']);
}
mysql_select_db($database, $conn);
$query_get_email = sprintf("SELECT Email as userlogon, Password as pw FROM tt_users WHERE Email = '%s'", $colname_get_email);
$get_email = mysql_query($query_get_email, $conn) or die(mysql_error());
$row_get_email = mysql_fetch_assoc($get_email);
$totalRows_get_email = mysql_num_rows($get_email);
//if so, send email
if ($totalRows_get_email == 1)
{//email on file, reset password and mail
$temp_pw = rand(10000000,99999999);
$updatesql = "UPDATE tt_users SET Password = $temp_pw WHERE Email = '$colname_get_email'";
$updated = mysql_query($updatesql, $conn) or die(mysql_error());
$body = "As requested, your password has been reset.\n";
$body .= "Your new password is: $temp_pw\n";
$body .= "Thanks!";
mail($email_address,$CompanyName." Logon",$body,"From:".$EmailFrom);
mysql_free_result($get_email);
//display email confirmation notice
echo '<font face="Verdana, Arial, Helvetica, sans-serif"><h1 align="center">Success</h1><p align="center"> Your password has been reset, and your temporary password has been mailed to: ' . $_POST["email_address"] . '</p></font><div align="center"><a href="index.php">Back to Login</a></div>';
}
else
{//if email not on file with us, display notification
echo '<font face="Verdana, Arial, Helvetica, sans-serif"><h1 align="center">Not on File</h1><p align="center">This email address is not on file with us.<br><br><input type="button" value="Back" onClick="window.location.href=\'forgot_password.php\';"></p></font>';
}
//allow user to try again
}
else
{//show form
?>
<h1 align="center"><font face="Verdana, Arial, Helvetica, sans-serif">Forgot Password</font></h1>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">If you have an account
with us, but have forgotten your password, simply enter the email address
on file with us, and we will immediately reset your password (to a new
temporary password) and email it to you.</font></p>
<form name="form1" method="post" action="forgot_password.php">
<table border="0" cellspacing="2" cellpadding="2" align="center">
<tr>
<td>
<font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">
<strong>Email Address</strong>
</font>
</td>
<td>
<div align="center">
<input type="text" name="email_address" style="background-color:#cccccc" onFocus="this.style.backgroundColor='#ffffcc'" onBlur="this.style.backgroundColor='#cccccc'" >
</div>
</td>
</tr>
<tr>
<td colspan="2">
<br>
<div align="center">
<input type="submit" name="Submit" value="Submit">
<input type="button" value="Back" onClick="window.location.href='index.php';">
</div>
</td>
</tr>
</table>
</form>
<?php
}
?>
<p> </p>
<p> </p>
<?php include("footer.php"); ?>
</body>
</html>