From 77afebbb3a362122bda1112952d477335ba4128a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 26 Jun 2018 18:07:15 +0900 Subject: [PATCH] Add: maestro login php --- src/web/main/index.html | 3 + src/web/module/header.html | 4 +- src/web/module/maestro_header.html | 14 ++++- src/web/module/maestro_section_login.html | 52 +++++++++++++---- src/web/server/maestro/login.php | 71 +++++++++++++++++++++++ src/web/server/setup/connect_db.php | 2 +- src/web/sql/make_db.sql | 2 +- 7 files changed, 131 insertions(+), 17 deletions(-) create mode 100644 src/web/server/maestro/login.php diff --git a/src/web/main/index.html b/src/web/main/index.html index 7176f89..7c839ac 100644 --- a/src/web/main/index.html +++ b/src/web/main/index.html @@ -11,6 +11,9 @@ + + +
첫 화면 - 마에스트로
로그아웃
+ 마에스트로
로그아웃
diff --git a/src/web/module/maestro_section_login.html b/src/web/module/maestro_section_login.html index 54e4dcf..b9bddab 100644 --- a/src/web/module/maestro_section_login.html +++ b/src/web/module/maestro_section_login.html @@ -10,30 +10,58 @@ } +
@@ -41,7 +69,7 @@
    diff --git a/src/web/server/maestro/login.php b/src/web/server/maestro/login.php new file mode 100644 index 0000000..e2ae411 --- /dev/null +++ b/src/web/server/maestro/login.php @@ -0,0 +1,71 @@ +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; +} + +?> \ No newline at end of file diff --git a/src/web/server/setup/connect_db.php b/src/web/server/setup/connect_db.php index b04c293..d4002d9 100644 --- a/src/web/server/setup/connect_db.php +++ b/src/web/server/setup/connect_db.php @@ -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(); } ?> \ No newline at end of file diff --git a/src/web/sql/make_db.sql b/src/web/sql/make_db.sql index 65158b8..a8c63cf 100644 --- a/src/web/sql/make_db.sql +++ b/src/web/sql/make_db.sql @@ -1,7 +1,7 @@ CREATE TABLE moty_maestro ( MaestroID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, Name CHAR(50) NOT NULL, - EnterCode CHAR(10) NOT NULL, + Password CHAR(10) NOT NULL, Email CHAR(50) NOT NULL, AccountType INT UNSIGNED NOT NULL, AccountStatus INT UNSIGNED NOT NULL,