<?php 

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


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

$successMsg = '';

if(isset($_REQUEST['successMsg'])){
	$successMsg = $_REQUEST['successMsg'];
}

if(isset($_REQUEST['failedMsg'])){
	$failedMsg = $_REQUEST['failedMsg'];
}

// Logical section of page
if(isset($_POST['submit'])){
	$new_password = $_POST['new_password'];
	$confirm_password = $_POST['confirm_password'];
	
	if($new_password!='' && $confirm_password!='' && $new_password==$confirm_password && $_POST['email_address']!=''){
		$adminObj->resetPassword($_POST['email_address'],md5($new_password));
		
		header ("Location:admin-login.php?successMsg=Your admin password reset successfully");
		exit;
		
	}else{
		header ("Location:admin-login.php?successMsg=New password and confirm password do not matched");
		exit;
	}
}

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

?>