Add: maestro login php

This commit is contained in:
2018-06-26 18:07:15 +09:00
parent f3b51ae5a2
commit 77afebbb3a
7 changed files with 131 additions and 17 deletions
+71
View File
@@ -0,0 +1,71 @@
<?php
header('Content-Type: application/json');
$maestro_name = $_POST["maestro_name"];
$password = $_POST["password"];
/*
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";
$maestro_id = get_maestro_id($maestro_name);
if($maestro_id === null) {
$replyJSON["ERROR"] = "마에스트로 아이디가 없습니다";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
}
$replyJSON = login($maestro_name, $password);
if($replyJSON === null || $replyJSON[MaestroID] === null) {
$replyJSON["ERROR"] = "비밀번호를 잘못 입력하셨습니다.";
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
}
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
exit;
function get_maestro_id($maestro_name) {
global $db_conn;
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('s', $maestro_name);
$stmt->execute();
$stmt->bind_result($maestro_id);
// while($stmt->fetch()) {
// ;
// }
$stmt->fetch();
$stmt->close();
return $maestro_id;
}
function login($maestro_name, $password) {
global $db_conn;
$query = "SELECT MaestroID FROM moty_maestro WHERE Name=? AND Password=?";
$stmt = $db_conn->prepare($query);
$stmt->bind_param('ss', $maestro_name, $password);
$stmt->execute();
$stmt->bind_result($maestro_id);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
$replyJSON["MaestroID"] = $maestro_id;
return $replyJSON;
}
?>
+1 -1
View File
@@ -24,8 +24,8 @@ $result = mysqli_query($db_conn, $query);
function send_error_message($replyJSON, $error_message) {
$replyJSON["ERROR"] = $error_message;
$db_conn->close();
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
$db_conn->close();
}
?>