<?php
if (isset($_GET['username']) && isset($_GET['password'])){
	$username = $_GET['username'];
	$password = hash("sha512",$_GET['password']);
	include_once("requestView.php");
	//Usage: RequestView ("view URL", "key"); --> Key is the MapReduce outcome key
	$results = requestView("auth/_design/chkauth/_view/authv1/",$username);
	if (count($results["rows"]) == 0){
		//Username not found.
		echo "Username Not Found.";
		exit(0);
	}
	//Check if the password hash match
	if ($results["rows"][0]["value"] == $password){
		echo "Password Correct";
	}else{
		echo "Password Incorrect";
	}
}else{
	//Some parameter missing
	die("Username or Password not defined.");
}

?>