<?php
header("Content-Type: application/json");

include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";

$maestroID = $_POST["maestro_id"];
$playerID = $_POST["player_id"];
/*
if(!is_numeric($enterCode)) {
    send_error_code("생년월일이 숫자가 아닙니다. : ".$enterCode);
    exit;
} else if(strlen($enterCode) != 6) {
    send_error_code("6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : ".$enterCode);
    exit;
}
*/


$enterCode = getEnterCode($maestroID, $playerID);
if($enterCode == NULL) {
	set_error_message("입장 코드 정보가 없습니다.");
	send_result_fail();
	exit;
}

set_data("EnterCode", $enterCode);
send_result_success();
exit;


function getEnterCode($maestroID, $playerID) {
	global $db_conn;

	$query = "SELECT EnterCode FROM player WHERE MaestroID=? AND PlayerID=?";
	$stmt = $db_conn->prepare($query);
	$stmt->bind_param("ii", $maestroID, $playerID);
	$stmt->execute();
	$stmt->bind_result($enterCode);
	// while($stmt->fetch())
	$stmt->fetch();
	$stmt->close();

	return $enterCode;
}

?>