include 'header.php';
session_start();
require('class/validation.php');
require("class/utilities.php");
$utilities = new utilities();
$validation = new Validation();
?>
//===========================================================
// Initialize Variables
//===========================================================
if (!$_SESSION['forgotPW'])
{
$ls_forgotPW_isSubmitted = $_POST["forgotPW_isSubmitted"];
$ls_forgotPW_email = $_POST["forgotPW_email"];
}
else
{
$ls_forgotPW_isSubmitted = "no";
}
?>
//===========================================================
// Validate the Password if the form has been submitted and the password has not already
// been validated
//===========================================================
if ($ls_forgotPW_isSubmitted == "yes" AND !$_SESSION["forgotPW"])
{
if ($validation->validateEmail($ls_forgotPW_email))
$lb_forgotPW_Validation = true;
else
$lb_forgotPW_Validation = false;
}
?>
if ($ls_forgotPW_isSubmitted == "yes" AND $lb_forgotPW_Validation AND !$_SESSION['forgotPW'])
{
// Connecting, selecting database
$link = mysql_connect('localhost', 'actualcy_itr', 'itr')
or die('Could not connect: ' . mysql_error());
// Setup DB
mysql_select_db('actualcy_itr')
or die('Could not select database');
// Performing SQL query
$query = "SELECT PASSWORD, FIRST_NAME, LAST_NAME FROM user WHERE EMAIL = '" . $ls_forgotPW_email . "'";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
// Make sure Querey was Valid
if (!$result)
{
// Todo.................
// Setup this section so that it gives the user a way to send this error to us via email.
die('Invalid query: ' . mysql_error());
}
// Check if we returned any rows
if (mysql_num_rows($result) > 0)
{
// Get the retrieved row
$row = mysql_fetch_row($result);
$lb_forgotPW_found = true;
$ls_forgotPW_password = $row[0]; // PASSWORD
$ls_forgotPW_first_name = $row[1]; // First Name
$ls_forgotPW_last_name = $row[2]; // Last Name
$_SESSION["forgotPW_email"] = $ls_forgotPW_email;
}
else
{
$_SESSION['email_not_found'] = true;
$lb_forgotPW_found = true;
$lb_forgotPW_Invalid_email = true;
}
// Free resultset
mysql_free_result($result);
// Closing connection
mysql_close($link);
}
?>
if ($ls_forgotPW_isSubmitted == "yes" AND $lb_forgotPW_Validation AND !$_SESSION["forgotPW"])
{
//*************************************************************************
//Send Email
//*************************************************************************
$emailSubject = "itrincwi.com User Password";
$emailBody = "Hello,
" .
"You are receiving this email because you are a user of itrincwi.com
" .
"and you filled out the forgot password form.
" .
"Your password is: " . $ls_forgotPW_password . "
" .
"Note: This e-mail was sent from an unmonitored account.
" .
"If you have any questions regarding this message
" .
"please contact us at http://www.itrincwi.com/contact/
" .
"The ITR Team
" .
"webmaster@itrincwi.com
" .
"http://www.itrincwi.com/";
if ($utilities->sendEmail("webmaster@itrincwi.com", "ITR Webmaster", $ls_forgotPW_email, $emailSubject, $emailBody))
$_SESSION["forgotPW"] = True;
else
{// Failed
}
}
?>
if (!$_SESSION["forgotPW"])
{
echo "
Please read our Privacy Policy.
©2005.
ITR. All Rights Reserved. Site Developed by Actual Cyber Solutions Inc.