Add: add maestro
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script type="text/javascript">
|
||||||
|
|
||||||
let maestro_name = "";
|
let maestro_name = "";
|
||||||
let isAvailableID = false;
|
let isAvailableID = false;
|
||||||
@@ -33,7 +33,8 @@ let isAvailableID = false;
|
|||||||
let password = "";
|
let password = "";
|
||||||
let email = "";
|
let email = "";
|
||||||
let accountType = 0;
|
let accountType = 0;
|
||||||
let selectedAccountTypeValue = "";
|
let selectedAccountTypeValue = -1;
|
||||||
|
let selectedAccountTypeText = "";
|
||||||
|
|
||||||
let tab1, tab2, tab3;
|
let tab1, tab2, tab3;
|
||||||
|
|
||||||
@@ -98,8 +99,10 @@ function check_data() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedAccountTypeValue = $("#account_type option:selected").text();
|
selectedAccountTypeValue = $("#account_type option:selected").val();
|
||||||
|
selectedAccountTypeText = $("#account_type option:selected").text();
|
||||||
console.log(selectedAccountTypeValue);
|
console.log(selectedAccountTypeValue);
|
||||||
|
console.log(selectedAccountTypeText);
|
||||||
|
|
||||||
let isCheckAcceptClauses = $("#check_accept_clauses").is(":checked");
|
let isCheckAcceptClauses = $("#check_accept_clauses").is(":checked");
|
||||||
if(!isCheckAcceptClauses) {
|
if(!isCheckAcceptClauses) {
|
||||||
@@ -111,8 +114,8 @@ function check_data() {
|
|||||||
$(".maestro_name").append(maestro_name);
|
$(".maestro_name").append(maestro_name);
|
||||||
$(".password").append(password);
|
$(".password").append(password);
|
||||||
$(".email").append(email);
|
$(".email").append(email);
|
||||||
$(".account_type").append(selectedAccountTypeValue);
|
$(".account_type").append(selectedAccountTypeText);
|
||||||
$(".price_account").append(selectedAccountTypeValue);
|
$(".price_account").append(selectedAccountTypeText);
|
||||||
|
|
||||||
$("#input_data").css("display", "none");
|
$("#input_data").css("display", "none");
|
||||||
$("#register_account").css("display", "block");
|
$("#register_account").css("display", "block");
|
||||||
@@ -127,6 +130,34 @@ function register_account() {
|
|||||||
|
|
||||||
tab2.removeClass("activated");
|
tab2.removeClass("activated");
|
||||||
tab3.addClass("activated");
|
tab3.addClass("activated");
|
||||||
|
|
||||||
|
let xhr = new XMLHttpRequest(); //new로 생성.
|
||||||
|
xhr.open('POST', './../server/maestro/add_maestro.php', true);
|
||||||
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
xhr.send("maestro_name=" + maestro_name + "&password=" + password + "&email=" + email + "&account_type=" + selectedAccountTypeValue);
|
||||||
|
xhr.onload = function() {
|
||||||
|
if(xhr.readyState === 4 && xhr.status === 200) {
|
||||||
|
let replyJSON = JSON.parse(xhr.responseText);
|
||||||
|
// console.log(replyJSON);
|
||||||
|
|
||||||
|
// if(replyJSON !== null)
|
||||||
|
// console.log(replyJSON);
|
||||||
|
|
||||||
|
// if(replyJSON["MaestroID"] !== undefined)
|
||||||
|
// console.log(replyJSON["MaestroID"]);
|
||||||
|
|
||||||
|
if(replyJSON !== null && replyJSON["Result"] !== undefined && replyJSON["Result"] === "ok") {
|
||||||
|
// sessionStorage.setItem("maestroID", replyJSON["MaestroID"]);
|
||||||
|
// location.href = './../maestro/main_menu.html';
|
||||||
|
isAvailableID = true;
|
||||||
|
} else {
|
||||||
|
isAvailableID = false;
|
||||||
|
$("#error_message").val(replyJSON["ERROR"]);
|
||||||
|
$("#maestro_name").val("");
|
||||||
|
$("#maestro_name").focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -146,15 +177,15 @@ function register_account() {
|
|||||||
|
|
||||||
<div id="input_data">
|
<div id="input_data">
|
||||||
|
|
||||||
(필수) 마에스트로 아이디 : <input type="text" id="maestro_name">
|
(필수) 마에스트로 아이디 : <input type="text" id="maestro_name" value="test" >
|
||||||
<button id="check_id" onClick="check_id()">중복 확인</button><br/>
|
<button id="check_id" onClick="check_id()">중복 확인</button><br/>
|
||||||
(필수) 암호 : <input id="password" type="password" name="password"><br/>
|
(필수) 암호 : <input id="password" value="test" type="password" name="password"><br/>
|
||||||
(필수) 이메일 : <input id="email" name="email"><br/>
|
(필수) 이메일 : <input id="email" value="test@test.com" name="email"><br/>
|
||||||
(필수) 학생 수 :
|
(필수) 학생 수 :
|
||||||
<select id="account_type">
|
<select id="account_type">
|
||||||
<option name="account_type" value="1">20명 (1만원 / 1년)</option>
|
<option name="account_type" value="1">20명 (1만원 / 1년)</option>
|
||||||
<option name="account_type" value="1">50명 (2만원 / 1년)</option>
|
<option name="account_type" value="2">50명 (2만원 / 1년)</option>
|
||||||
<option name="account_type" value="1">100명 (3만원 / 1년)</option>
|
<option name="account_type" value="3">100명 (3만원 / 1년)</option>
|
||||||
</select>
|
</select>
|
||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user