<?php
include_once("header.html");
if(!isset($email)) include("forgottenpassword.html");
else
{
$dbc = dbc::instance();
$correct_email = 0;
$query = "SELECT id,their_username,contact_email FROM wmm_admin WHERE their_username=:email";
$result = $dbc->prepare($query);
$result->bindParam(':email', $email, PDO::PARAM_STR);
$rows = $dbc->executeGetRows($result);
if (count($rows)>0) $row = $rows[0];//username is same as provided email
$query = "SELECT id,their_username,contact_email FROM wmm_admin WHERE contact_email=:email";
$result = $dbc->prepare($query);
$result->bindParam(':email', $email, PDO::PARAM_STR);
$rows = $dbc->executeGetRows($result);
if (count($rows)>0) $row = $rows[0];//contact email is same as provided email
if (isset($row))
{
$contact_email = $row['contact_email'];
$their_username = $row['their_username'];
$their_password = random_password(8);
$cpass = WMMcrypt($their_password,$their_username);
$result = $dbc->prepare("update wmm_admin set their_password='$cpass' where id='1' ");
$result = $dbc->execute($result);
include("password_changed_email.php");
$feedback->setShow("New password has been sent to $email - please check your mailbox.");
}
else $feedback->setShow("$email <br>NOT FOUND. Checked both the updated email address and original username!");
include_once("header.html");
include("login.html");
include("footer.html");
}
?>