Add: additional DB tables
This commit is contained in:
@@ -21,4 +21,10 @@ if ($db_conn->connect_error) {
|
||||
$query = "USE jisangs";
|
||||
$result = mysqli_query($db_conn, $query);
|
||||
|
||||
|
||||
function send_error_message($replyJSON, $error_message) {
|
||||
$replyJSON["ERROR"] = $error_message;
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -18,32 +18,56 @@ if(!is_numeric($enterCode)) {
|
||||
|
||||
include "./../setup/connect_db.php";
|
||||
|
||||
$return_array = array();
|
||||
$maestro_id = get_maestro_id($maestro_name);
|
||||
if($maestro_id == null) {
|
||||
send_error_message($replyJSON, "no maestro id");
|
||||
exit;
|
||||
}
|
||||
|
||||
$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();
|
||||
$replyJSON = get_login_data($maestro_id, $name, $enterCode);
|
||||
if($replyJSON["UserID"] == null) {
|
||||
send_error_message($replyJSON, "invalid username and entercode");
|
||||
exit;
|
||||
}
|
||||
|
||||
// $maestro_id = 1;
|
||||
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND enterCode=?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('iss', $maestro_id, $name, $enterCode);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($user_id);
|
||||
// while($stmt->fetch())
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
$db_conn->close();
|
||||
echo json_encode($replyJSON, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
$jsonUserData["MaestroID"] = $maestro_id;
|
||||
$jsonUserData["UserID"] = $user_id;
|
||||
echo json_encode($jsonUserData, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
|
||||
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 get_login_data($maestro_id, $name, $enterCode) {
|
||||
global $db_conn;
|
||||
|
||||
$query = "SELECT UserID FROM moty_user WHERE MaestroID=? AND Name=? AND enterCode=?";
|
||||
$stmt = $db_conn->prepare($query);
|
||||
$stmt->bind_param('iss', $maestro_id, $name, $enterCode);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($user_id);
|
||||
// while($stmt->fetch())
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
$db_conn->close();
|
||||
|
||||
$replyJSON["MaestroID"] = $maestro_id;
|
||||
$replyJSON["UserID"] = $user_id;
|
||||
|
||||
return $replyJSON;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user