<?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'] : '';

// Logical section of page

if(isset($_POST['submit'])){
	$new_password = $_POST['user_newpassword'];
	$confirm_password = $_POST['user_newrepassword'];
       
	if($new_password!='' && $confirm_password!='' && $new_password==$confirm_password && $_POST['user_email_address']!=''){
		
        $adminEmail = base64_decode($_POST['user_email_address']);
        $adminObj->resetPassword($adminEmail,md5($new_password));
		$successMsg = base64_encode("Your password reset successfully");
		header ("Location:admin-login.php?successMsg=".$successMsg);
		exit;
		
	}else{
		$failedMsg = base64_encode("New password and confirm password do not matched");
		header ("Location:resetpassword.php?user=".$_POST['user_email_address']."&failedMsg=".$failedMsg);
		exit;
	}
}

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

?>