diff --git a/api/BuoiHoc.php b/api/getData/BuoiHoc.php similarity index 100% rename from api/BuoiHoc.php rename to api/getData/BuoiHoc.php diff --git a/api/LopMH.php b/api/getData/LopMH.php similarity index 100% rename from api/LopMH.php rename to api/getData/LopMH.php diff --git a/api/MonHoc.php b/api/getData/MonHoc.php similarity index 100% rename from api/MonHoc.php rename to api/getData/MonHoc.php diff --git a/api/getmonhoc.php b/api/getData/getmonhoc.php similarity index 98% rename from api/getmonhoc.php rename to api/getData/getmonhoc.php index 7ccca7f..caf4750 100644 --- a/api/getmonhoc.php +++ b/api/getData/getmonhoc.php @@ -12,7 +12,7 @@ require "MonHoc.php"; require "LopMH.php"; require "BuoiHoc.php"; -require "../config.php"; +require "../../config.php"; $ds_monhoc = array(); diff --git a/api/sign/getStatus.php b/api/sign/getStatus.php new file mode 100644 index 0000000..841ec29 --- /dev/null +++ b/api/sign/getStatus.php @@ -0,0 +1,14 @@ + $status, "user" => $user]); + } +?> diff --git a/api/sign/signin.php b/api/sign/signin.php new file mode 100644 index 0000000..751a56e --- /dev/null +++ b/api/sign/signin.php @@ -0,0 +1,55 @@ + 0) { + $row = mysqli_fetch_array($result, MYSQL_ASSOC); + $pass = $row['pass']; + return $pass; + } + + return false; +} + +function getName($username) { + global $conn; + $sql = "select name from nguoidung where email = '$username'"; + $result = mysqli_query($conn, $sql); + + if (mysqli_num_rows($result ) > 0) { + $row = mysqli_fetch_array($result, MYSQL_ASSOC); + $name = $row['name']; + if ($name == "") { + return $username; + } + return $name; + } + + return "Bạn"; +} + +function echoJson($result) { + echo json_encode(array("result" => $result)); +} + +if (isset($_POST['user']) and isset($_POST['pass'])) { + $pass = getPassword($_POST['user']); + if ($pass == false) { + echoJson(false); + } else { + if (md5( $_POST['pass']) == $pass) { + $_SESSION['user'] = getName($_POST['user']); + echoJson(true); + } else { + echoJson(false); + } + } +} +else { + echoJson(false); +} \ No newline at end of file diff --git a/api/sign/signout.php b/api/sign/signout.php new file mode 100644 index 0000000..7b68525 --- /dev/null +++ b/api/sign/signout.php @@ -0,0 +1,5 @@ + +