Add: player list manager
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$maestroID = $_POST["maestro_id"];
|
||||
$playerName = $_POST["player_name"];
|
||||
$enterCode = $_POST["enter_code"];
|
||||
/*
|
||||
if(!is_numeric($enterCode)) {
|
||||
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
|
||||
exit;
|
||||
} else if(strlen($enterCode) != 6) {
|
||||
send_error_code('6자리 숫자값을 정확히 입력하세요 : YYMMDD (예 : 120131) : '.$enterCode);
|
||||
exit;
|
||||
}
|
||||
*/
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$result = hasPlayerName($maestroID, $playerName, $enterCode);
|
||||
if($result !== null) {
|
||||
send_error_message($replyJSON, "이미 등록된 학생과 입장 코드 정보입니다.");
|
||||
// $db_conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
addPlayer($maestroID, $playerName, $enterCode);
|
||||
|
||||
$result = hasPlayerName($maestroID, $playerName, $enterCode);
|
||||
if($result === null) {
|
||||
send_result_message($replyJSON, "fail");
|
||||
exit;
|
||||
} else {
|
||||
send_result_message($replyJSON, "success");
|
||||
exit;
|
||||
}
|
||||
|
||||
// echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
// $db_conn->close();
|
||||
|
||||
|
||||
function hasPlayerName($maestroID, $playerName, $enterCode) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND EnterCode=?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($userID);
|
||||
// while($stmt->fetch())
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
// $replyJSON["UserID"] = $userID;
|
||||
return $userID;
|
||||
}
|
||||
|
||||
function addPlayer($maestroID, $playerName, $enterCode) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "INSERT INTO moty_user (MaestroID, Name, EnterCode) VALUES (?, ?, ?)";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('iss', $maestroID, $playerName, $enterCode);
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user