Add: update maestro info, password php

This commit is contained in:
2018-08-02 17:27:18 +09:00
parent e2e6761c9b
commit fd87b6fe45
5 changed files with 338 additions and 20 deletions
+4 -2
View File
@@ -15,6 +15,7 @@ if($info === null) {
}
set_data("name", $info["name"]);
set_data("email", $info["email"]);
set_data("accountType", $info["accountType"]);
set_data("playerCount", $info["playerCount"]);
send_result_success();
@@ -25,19 +26,20 @@ function get_maestro_info($maestroID) {
global $db_conn;
$query = "
SELECT Name, AccountType, PlayerCount
SELECT Name, Email, AccountType, PlayerCount
FROM moty_maestro
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("s", $maestroID);
$stmt->execute();
$stmt->bind_result($name, $accountType, $playerCount);
$stmt->bind_result($name, $email, $accountType, $playerCount);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
$info["name"] = $name;
$info["email"] = $email;
$info["accountType"] = $accountType;
$info["playerCount"] = $playerCount;
@@ -0,0 +1,31 @@
<?php
header("Content-Type: application/json");
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestroID = $_POST["maestro_id"];
$maestroName = $_POST["maestro_name"];
$email = $_POST["email"];
update_maestro_info($maestroID, $maestroName, $email);
send_result_success();
exit;
function update_maestro_info($maestroID, $maestroName, $email) {
global $db_conn;
$query = "
UPDATE moty_maestro
SET Name = ?, Email = ?
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("ssi", $maestroName, $email, $maestroID);
$stmt->execute();
}
?>
@@ -0,0 +1,57 @@
<?php
header("Content-Type: application/json");
include "./../lib/send_reply_json.php";
include "./../setup/connect_db.php";
$maestroID = $_POST["maestro_id"];
$registeredPW = $_POST["registered_pw"];
$newPW = $_POST["new_pw"];
$countResult = maestro_registered_password($maestroID, $registeredPW);
if($countResult === null || $countResult < 1) {
set_error_message("입력하신 [현재 암호]가 맞지 않습니다.");
send_result_fail();
exit;
}
update_maestro_password($maestroID, $newPW);
send_result_success();
exit;
function maestro_registered_password($maestro_id, $registeredPW) {
global $db_conn;
$query = "
SELECT COUNT(MaestroID)
FROM moty_maestro
WHERE MaestroID = ? AND Password = PASSWORD(?)
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("is", $maestro_id, $registeredPW);
$stmt->execute();
$stmt->bind_result($countResult);
// while($stmt->fetch())
$stmt->fetch();
$stmt->close();
return $countResult;
}
function update_maestro_password($maestroID, $newPW) {
global $db_conn;
$query = "
UPDATE moty_maestro
SET Password = PASSWORD(?)
WHERE MaestroID = ?
";
$stmt = $db_conn->prepare($query);
$stmt->bind_param("si", $newPW, $maestroID);
$stmt->execute();
}
?>