<?php

header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Credentials: true');
header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-Type: application/json; charset=UTF-8");

include_once("../database.php");
$postData = file_get_contents("php://input");

if(isset($postData) && !empty($postData)){
    $request = json_decode($postData);
    $title = mysqli_real_escape_string($mysqli, trim($request->title));
    $out1 = mysqli_real_escape_string($mysqli, trim($request->out1));
    $out2 = mysqli_real_escape_string($mysqli, trim($request->out2));

    $sql = "SELECT out1, out2 FROM questions WHERE title='$title'";

    if($result = mysqli_query($mysqli,$sql)->fetch_all()){
        $bool = array(0,0);
        if(result['out1'] === $out1){ 
            $bool[0]=1;
        }
        if(result['out2'] === $out2){
            $bool[1]=1;
        }

        echo json_encode($bool);
    }
    else{
        http_response_code(404);
    }
    



}

?>