<?php
 
 header("Access-Control-Allow-Origin: http://localhost/rest-api-authentication-example/");
//header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
 
// files needed to connect to database

 $pathRoot = $_SERVER['DOCUMENT_ROOT'];
include_once  $pathRoot ."/saia/api/v1/config/database.php";
include_once $pathRoot ."/saia/api/v1/objects/appUser.php";
 
// get database connection
$database = new Database();
$db = $database->getConnection();
//==================Generate Verification Code =================================

$data = json_decode(file_get_contents("php://input"));

// instantiate AppUser object
$user = new AppUser($db);
// set product property values

$user->email = $data->email;
 $emailExists = $user->emailExists();
    if($emailExists == true){
         echo json_encode(array("found" => "Yes")); 
    }else{
        echo json_encode(array("found" => "No")); 
    }

?> 