<?php 

include_once ("includes/setup_pemohon.inc.php");

$username = fetch_postget_val('username',$_POST, $_GET);
$outputResult = [];

$indicator_Query = "SELECT t_pemohon.id_pemohon, i_soalanrahsia.id_soalanrahsia, i_soalanrahsia.desk_soalanrahsia
				  FROM t_pemohon
				  LEFT JOIN i_soalanrahsia ON i_soalanrahsia.id_soalanrahsia = t_pemohon.id_soalanrahsia
				  WHERE login = ?";
$PDO_stmt = $PDO->prepare($indicator_Query);
$PDO_stmt->bindValue(1, $username, PDO::PARAM_STR);
$PDO_stmt->execute();
$check_result = $PDO_stmt->fetch(PDO::FETCH_ASSOC);
if($check_result['id_pemohon'] == 0)//tidak wujud dalam system
{
	$outputResult['status'] = -1;
	$outputResult['error'] = 'Id Pengguna tidak wujud dalam sistem.';
}
else if($check_result['id_soalanrahsia'] == 0)//tiada soalan rahsia
{
	$outputResult['status'] = -2;
	$outputResult['error'] = 'Tiada soalan rahsia dalam sistem.';
}
else
{
	$outputResult['status'] = 1;
	$outputResult['soalan'] = $check_result['desk_soalanrahsia'];
}

echo json_encode($outputResult);
?>