Fix: revised php code to maestro register

This commit is contained in:
2018-07-12 11:27:17 +09:00
parent 07b65f004b
commit a0e0702370
3 changed files with 55 additions and 75 deletions
+30 -45
View File
@@ -47,34 +47,26 @@ $(document).ready(function() {
function check_id() {
maestro_name = $("#maestro_name").val();
let xhr = new XMLHttpRequest(); //new로 생성.
xhr.open('POST', './../server/maestro/check_id.php', true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("maestro_name=" + maestro_name);
xhr.onload = function() {
if(xhr.readyState === 4 && xhr.status === 200) {
let replyJSON = JSON.parse(xhr.responseText);
// console.log(replyJSON);
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/check_id.php",
"maestro_name=" + maestro_name,
// if(replyJSON !== null)
// console.log(replyJSON);
(jsonData) => {
isAvailableID = true;
},
// if(replyJSON["MaestroID"] !== undefined)
// console.log(replyJSON["MaestroID"]);
(errorMessage) => {
isAvailableID = false;
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();
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
}
}
$("#maestro_name").val("");
$("#maestro_name").focus();
}
);
}
@@ -131,33 +123,26 @@ function register_account() {
tab2.removeClass("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);
sendRequestServer( //url, sendParams, onSuccess, onFail, isDebugMode);
"./../server/maestro/add_maestro.php",
"maestro_name=" + maestro_name + "&password=" + password + "&email=" + email + "&account_type=" + selectedAccountTypeValue,
// if(replyJSON !== null)
// console.log(replyJSON);
(jsonData) => {
isAvailableID = true;
},
// if(replyJSON["MaestroID"] !== undefined)
// console.log(replyJSON["MaestroID"]);
(errorMessage) => {
isAvailableID = false;
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();
if($("#error_message").length) {
$("#error_message").text(errorMessage);
}
$("#maestro_name").val("");
$("#maestro_name").focus();
}
}
);
}
</script>