From 3fc902bb0414f62b085ca34a0e8558aacbebf93e Mon Sep 17 00:00:00 2001 From: Agnibho Mondal Date: Sat, 15 May 2021 03:30:09 +0530 Subject: [PATCH] Added login --- admission.php | 10 ++++++++++ attachments.php | 5 +++++ clinical.php | 5 +++++ death.php | 5 +++++ discharge.php | 5 +++++ history.php | 5 +++++ index.php | 5 +++++ laboratory.php | 5 +++++ lib/db.php | 9 ++++++++- login.php | 39 +++++++++++++++++++++++++++++++++++++++ report.php | 5 +++++ schema.sql | 8 ++++++++ treatment.php | 5 +++++ view.php | 5 +++++ 14 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 login.php diff --git a/admission.php b/admission.php index d8799f4..6864344 100644 --- a/admission.php +++ b/admission.php @@ -1,6 +1,16 @@ admit($_POST); //header("Location: view.php?pid=".$_POST["pid"]); diff --git a/attachments.php b/attachments.php index fde5c41..6bc4833 100644 --- a/attachments.php +++ b/attachments.php @@ -1,6 +1,11 @@ "; $imgs="
"; $pdfs="
"; diff --git a/clinical.php b/clinical.php index 97b1568..1e580d6 100644 --- a/clinical.php +++ b/clinical.php @@ -1,6 +1,11 @@ getList(); $show=""; if(!empty($list)){ diff --git a/laboratory.php b/laboratory.php index c20784f..6462ec7 100644 --- a/laboratory.php +++ b/laboratory.php @@ -1,5 +1,10 @@ open("data/data.db"); } + function checkUser($username, $password){ + $stmt=$this->prepare("SELECT hash FROM users WHERE user=:user"); + $stmt->bindValue(":user", $username); + $result=$stmt->execute(); + return(password_verify($password, $result->fetchArray()[0])); + } function admit($post){ $quer=$this->prepare("SELECT count(rowid) FROM patients WHERE pid=:pid"); $quer->bindValue(":pid", $post["pid"]); @@ -76,7 +82,8 @@ class DB extends SQLite3 { $stmt->execute(); } function omitDrug($id){ - $stmt=$this->prepare("UPDATE treatment SET omit=:omit WHERE rowid=:id;"); + $stmt=$this->prepare("UPDATE treatment SET end=:end,omit=:omit WHERE rowid=:id;"); + $stmt->bindValue(":end", time()); $stmt->bindValue(":omit", true); $stmt->bindValue(":id", $id); $stmt->execute(); diff --git a/login.php b/login.php new file mode 100644 index 0000000..9b489f1 --- /dev/null +++ b/login.php @@ -0,0 +1,39 @@ +checkUser($_POST["username"], $_POST["password"])){ + $_SESSION["user"]=$_POST["username"]; + header("Location: index.php"); + exit(); + } + else{ + $error="
Username or password is incorrect.
"; + } +} +//header("Location: view.php?id=".$_GET["id"]); +//exit(); +?> + + + + + Login + + +
+ +
+ + + +
+
+ + + diff --git a/report.php b/report.php index 6abf5c8..d21f96c 100644 --- a/report.php +++ b/report.php @@ -1,6 +1,11 @@