<?@include_once("settings.php");?>
<?
	if (isset($_REQUEST['confirm'])){
		if (isset($_REQUEST['email'])){
			$email = $_REQUEST['email'];
			$SQL = "SELECT * from tbl_user WHERE user_login='".$email."';";
			$count=$qry->numRows($SQL);
			if ($count){
				$newpassword = $lib->createRandomPassword();
				$SQL = "UPDATE tbl_user SET user_password='".$newpassword."' WHERE user_login='".$email."';";
				$qry->queryExecute($SQL);
				$mailcontent = "Password : ".$newpassword;
				mail($email,"Reset Password from IMS",$mailcontent);
			}
		}
		echo "<script>alert('Email sent.');parent.thickboxDone();</script>";
	}else{
		echo "<center><font face='Arial' size='-1'><b>Please enter your registered email address.</b></font><br>";
		echo "<form name='forget' method='post' action=''>";
		echo "<table><tr><td><font face='Arial' size='-1'><b>Email Address: </b></font></td><td><font face='Arial' size='-1' color='red'><input type='text' name='email' id='item_name' value='".$item_name."'></font></td></tr>";
		echo "</table><br>";
		echo "<input type='submit' name='confirm' value='Generate Password'><input type='button' value='Cancel' onclick='parent.thickboxDone();'>";
		echo "</form></center>";
	}
?>
