Add: add maestro

This commit is contained in:
2018-07-09 09:20:18 +09:00
parent a322d0c4c3
commit 2d4143fca3
2 changed files with 107 additions and 10 deletions
+66
View File
@@ -0,0 +1,66 @@
<?php
header('Content-Type: application/json');
$maestro_name = $_POST["maestro_name"];
$password = $_POST["password"];
$email = $_POST["email"];
$account_type = $_POST["account_type"];
/*
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";
$maestroID = hasMaestroName($maestro_name);
if($maestroID !== null) {
send_error_message($replyJSON, $maestro_name." : 이미 등록된 마에스트로 계정입니다.");
// $db_conn->close();
exit;
}
addMaestro($maestro_name, $password, $email, $account_type);
$maestroID = hasMaestroName($maestro_name);
if($maestroID === null) {
send_error_message($replyJSON, $maestro_name." : 알 수 없는 이유로 마에스트로 계정 등록이 취소되었습니다.");
exit;
}
$replyJSON["RESULT"] = "success";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
function hasMaestroName($maestroName) {
global $db_conn;
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('s', $maestroName);
$stmt->execute();
$stmt->bind_result($maestroID);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
return $maestroID;
}
function addMaestro($maestro_name, $password, $email, $account_type) {
global $db_conn;
$query = "
INSERT INTO moty_Maestro (Name, Password, Email, AccountType, ActivateStatus, UserCount, AcceptClausesDateTime, MaestroTestID)
VALUES (?, PASSWORD(?), ?, ?, 0, 0, NOW(), -1)";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('sssi', $maestro_name, $password, $email, $account_type);
$stmt->execute();
}
?>