Fix: revised php code to maestro search

This commit is contained in:
2018-07-12 10:55:44 +09:00
parent 7aa212ee47
commit f23665a5f0
12 changed files with 339 additions and 227 deletions
+14 -20
View File
@@ -1,37 +1,31 @@
<?php
header('Content-Type: application/json');
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;
}
*/
include "./../setup/connect_db.php";
deletePlayer($maestroID, $playerID);
$result = hasPlayerID($maestroID, $playerID);
if($result === true) {
send_result_message($replyJSON, "학생 계정 삭제 실패");
set_error_message("학생 계정 삭제 실패");
send_result_fail();
exit;
}
$result = hasPlayerRecord($maestroID, $playerID);
if($result === true) {
send_result_message($replyJSON, "학생 플레이 기록 삭제 실패");
set_error_message("학생 플레이 기록 삭제 실패");
send_result_fail();
exit;
}
$replyJSON["RESULT"] = "success";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
send_result_success();
exit;
function deletePlayer($maestroID, $playerID) {
@@ -39,7 +33,7 @@ function deletePlayer($maestroID, $playerID) {
$query = "DELETE FROM moty_best_record WHERE MaestroID = ? AND PlayerID = ?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$stmt->bind_param("ii", $maestroID, $playerID);
$result = $stmt->execute();
$stmt->close();
@@ -49,7 +43,7 @@ function deletePlayer($maestroID, $playerID) {
$query = "DELETE FROM moty_player WHERE MaestroID = ? AND PlayerID = ?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$stmt->bind_param("ii", $maestroID, $playerID);
$result = $stmt->execute();
$stmt->close();
@@ -63,7 +57,7 @@ function hasPlayerID($maestroID, $playerID) {
$query = "SELECT PlayerID FROM moty_player WHERE MaestroID=? AND PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$stmt->bind_param("ii", $maestroID, $playerID);
$stmt->execute();
$stmt->bind_result($playerID);
// while($stmt->fetch())
@@ -81,7 +75,7 @@ function hasPlayerRecord($maestroID, $playerID) {
$query = "SELECT PlayerID FROM moty_best_record WHERE MaestroID=? AND PlayerID=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ii', $maestroID, $playerID);
$stmt->bind_param("ii", $maestroID, $playerID);
$stmt->execute();
$stmt->bind_result($playerID);
// while($stmt->fetch())