<?php 

// Include main file
include_once('../libs/main.php');


// Object Creation 
$adminObj = new admin();

$successMsg =  isset($_REQUEST['successMsg']) ? $_REQUEST['successMsg'] : '';
$failedMsg = isset($_REQUEST['failedMsg']) ? $_REQUEST['failedMsg'] : '';

if(isset($_POST['submit'])){
	
		$result = $adminObj->getDetailFromEmail($_POST['forgot_email']);
		if($result){
			
			$From_Display = SITE_NAME;
			$From_Email   = ADMIN_EMAIL;
			
			$Subject="Your password Reset link to ".SITE_NAME;
			$Message = "<font face=\"verdana\" size=\"2\">Dear ".$result->first_name."  ".$result->last_name."<br><br>";
			$Message .= "You recently asked to have your username and password. Please reset your password on below links :<br><br>";
			$Message .=  "<a href='".SITE_URL.ADMIN_DIR."/resetpassword.php?user=".base64_encode($result->admin_email_address)."' > ".SITE_URL.ADMIN_DIR."/resetpassword.php?user=".base64_encode($result->admin_email_address)." </a>  <br><br>";
			$Message .= "Thank you.<br>".SITE_NAME." Team.</font>";
			
			SendMailCommon($From_Display,$From_Email,"",$result->admin_email_address, "","", $Subject,EMAIL_HEADER.$Message.EMAIL_FOOTER);
			$successMsg = base64_encode("Password reset link send to your email address");			
		    header ("Location:admin-login.php?successMsg=".$successMsg);
		    exit;
		}
		else{
			$failedMsg = base64_encode("No such email address exist.");			
			header("Location:forgotpassword.php?failedMsg=".$failedMsg);
			exit;
		}
}

// Include Template 
include_once('../libs/routs.php')

?>