<?php
$lcheck = "b";
$z = "b";
include("config.php");

global $setting;

eval (" ?>" . headera() . " <?php ");

echo "<form method = 'post' action='forgotpw.php?load=submit'><table cellspacing=\"0\" cellpadding=\"3\" border=\"0\" align=\"center\"><br><tr><td>Username </td><td><input type='text' name='username'></td></tr><br><tr><td>E-mail </td><td><input type='text' name='email'></td></tr></table></br>";

echo "<center><input type='submit' value='Submit'/></center></p></form>";


if ($_GET['load'] == "submit")
{

if ($_POST['email'] == "") {
echo "Please enter an e-mail address!";
die;
}

if (checkemail($_POST['email']) == TRUE) {

$check = mysql_num_rows(mysql_query("SELECT * FROM ".$pre."users WHERE username = '".$_POST['username']."' AND email = '".$_POST['email']."'"));
if ($check == '0') {
echo "E-mail address is not in our system.";
} else {

    $random_password = randomPassword(); 
    $db_password = md5($random_password); 
     
    $sql = mysql_query("UPDATE ".$pre."users SET password='$db_password' WHERE email='".$_POST['email']."'"); 
     
    $subject = "New $setting[sitename] Password"; 
    $message = "Hello, 
	
	We have recieved a request to reset the password associated with the above account, we have gone ahead and done this for you. 
     
    New Password: $random_password
     
    $setting[siteurl]login.html
	
    After logging in, please feel free to change your password at the following link if required,
	
	$setting[siteurl]index.php?load=members&view=changepass
	
	If you recieved this e-mail in error, please disregard it.
	
	If you have any questions do not reply to his e-mail, contact $setting[email] with a copy of this e-mail.
     
    Thanks!
	
	
    $setting[sitename]";
     
    mail($_POST['email'], $subject, $message, "From: ".$setting[sitename]." Webmaster<".$setting[email].">\n 
        X-Mailer: PHP/" . phpversion()); 
    echo "Your new password has been sent, please check your e-mail!<br />";
	
}
} else if (checkemail($_POST['email']) == FALSE) {
echo "Enter a valid email!";
die;
}
}

eval (" ?>" . footera() . " <?php ");
?>