Fix: send request / receive json data

This commit is contained in:
2018-07-10 18:03:46 +09:00
parent 7fe64c7a45
commit b5b56e8c2d
8 changed files with 175 additions and 87 deletions
+15 -15
View File
@@ -1,9 +1,11 @@
<?php
header('Content-Type: application/json');
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestro_name = $_POST["maestro_name"];
$password = $_POST["password"];
/*
if(!is_numeric($enterCode)) {
send_error_code('생년월일이 숫자가 아닙니다. : '.$enterCode);
@@ -14,28 +16,26 @@ if(!is_numeric($enterCode)) {
}
*/
include "./../setup/connect_db.php";
$maestro_id = get_maestro_id($maestro_name);
if($maestro_id === null) {
$replyJSON["ERROR"] = "마에스트로 아이디가 없습니다";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
set_error_message("등록되지 않은 마에스트로 아이디니다.");
send_result_fail();
exit;
}
$replyJSON = login($maestro_name, $password);
if($replyJSON === null || $replyJSON[MaestroID] === null) {
$replyJSON["ERROR"] = "비밀번호를 잘못 입력하셨습니다.";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
$login_data = login($maestro_name, $password);
if($login_data === null || $login_data[maestroID] === null) {
set_error_message("비밀번호가 틀렸습니다.");
send_result_fail();
exit;
}
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
set_data("maestroId", $login_data[maestroID]);
send_result_success();
exit;
function get_maestro_id($maestro_name) {
global $db_conn;
@@ -65,8 +65,8 @@ function login($maestro_name, $password) {
$stmt->fetch();
$stmt->close();
$replyJSON["MaestroID"] = $maestro_id;
return $replyJSON;
$result["maestroID"] = $maestro_id;
return $result;
}
?>