<?php

require_once '../includes/DbOperations.php';

$response = array();

if($_SERVER['REQUEST_METHOD'] == 'POST'){


	if(!empty($_POST['username']) and !empty($_POST['email'])) {
		if(isset($_POST['username']) and isset($_POST['email'])) {
			$db =  new DbOperations();

			$result = $db -> passreset( $_POST['username'],$_POST['email']);
	

	if($result == 1){
				
				$response['error'] = false;
				$response['message'] = "Kindly check your email. Password reset CODE is sent.";	
			}
			elseif($result == 0){
				$response['error'] = true;
				$response['message'] = "Password Reset Failed. Kindly check username / email";
			}

	}else{
		echo "no";
	}
}else{
			$response['error'] = true;
			$response['message'] = "Required fields are missing";
		}
}else{
	$response['error'] = true;
	$response['message'] = "Invalid Request";
}

echo json_encode($response);
?>