From 4d259c5f3869c352f73bdac3e10af3277025c554 Mon Sep 17 00:00:00 2001 From: Darrel Israel Date: Wed, 5 Jun 2024 10:20:44 +0800 Subject: [PATCH] doctor can now be stored in the database, renamed a file to show its purpose --- adminfieldset.php | 4 +- adminindex.php | 4 +- assets/js/a.js | 4 +- login.php | 7 ++- loginassets/css/style.css | 4 +- loginassets/js/{1.js => login.js} | 0 saveuser.php | 76 ++++++++++++++++++++++++++----- 7 files changed, 77 insertions(+), 22 deletions(-) rename loginassets/js/{1.js => login.js} (100%) diff --git a/adminfieldset.php b/adminfieldset.php index 60bef55..33a5cfb 100644 --- a/adminfieldset.php +++ b/adminfieldset.php @@ -53,8 +53,8 @@

- - + +
diff --git a/adminindex.php b/adminindex.php index a9b675d..53c276d 100644 --- a/adminindex.php +++ b/adminindex.php @@ -88,7 +88,7 @@ if (!isset($_SESSION["isAdmin"])) { include 'admintables.php'; ?> - + diff --git a/assets/js/a.js b/assets/js/a.js index 00f22ff..047fdad 100644 --- a/assets/js/a.js +++ b/assets/js/a.js @@ -1,4 +1,6 @@ - function togglePasswordVisibility(inputId, iconId) { +// edit this js file, separate the functions inside + +function togglePasswordVisibility(inputId, iconId) { var passwordField = document.getElementById(inputId); var eyeIcon = document.getElementById(iconId); diff --git a/login.php b/login.php index f9e6142..bbec40d 100644 --- a/login.php +++ b/login.php @@ -1,6 +1,5 @@ - Login @@ -13,11 +12,11 @@ - - + + - +
diff --git a/loginassets/css/style.css b/loginassets/css/style.css index 5fb638b..78fd565 100644 --- a/loginassets/css/style.css +++ b/loginassets/css/style.css @@ -8190,7 +8190,9 @@ h1, h2, h3, h4, h5, .img { background-size: cover; background-repeat: no-repeat; - background-position: center center; } + background-position: center center; + background-image: url(/loginassets/images/bg.jpg); +} .login-wrap { position: relative; diff --git a/loginassets/js/1.js b/loginassets/js/login.js similarity index 100% rename from loginassets/js/1.js rename to loginassets/js/login.js diff --git a/saveuser.php b/saveuser.php index 3c4216a..8d526df 100644 --- a/saveuser.php +++ b/saveuser.php @@ -7,30 +7,36 @@ if (!isset($_SESSION['isAdmin'])) { header('Location: login.php'); } -if (isset($_POST["btnSaveUser"])) { +if (isset($_POST["btnSaveUser"])) +{ $pw1 = $_POST['userPass']; $pw2 = $_POST['confirmUserPass']; - if ($pw1 == $pw2) { + if ($pw1 == $pw2) + { $fname = $_POST['fname']; $mname = $_POST['mname']; $lname = $_POST['lname']; $address = $_POST['address']; $phonenum = $_POST['phonenum']; $userpos = $_POST['UserPos']; + $licensenum = $_POST['licensenum']; + $specialization = $_POST['specialization']; $username = $_POST['username']; $password = $_POST['userPass']; // Hash the password $hashedPassword = password_hash($password, PASSWORD_DEFAULT); - if ($userpos == 'isSec') { + if ($userpos == 'isSec') + { // Insert data into tblsec $sql = "INSERT INTO tblsec (fname, mname, lname, phonenum, address) VALUES ('$fname', '$mname', '$lname', '$phonenum', '$address')"; $result = mysqli_query($conn, $sql); - if ($result) { + if ($result) + { // Get the userid of the last inserted row in tblsec $secIDFK = mysqli_insert_id($conn); @@ -38,24 +44,70 @@ if (isset($_POST["btnSaveUser"])) { $sql2 = "INSERT INTO tbluserroles (isSec, secIDFK) VALUES (1, $secIDFK)"; $result2 = mysqli_query($conn, $sql2); - if ($result2) { + if ($result2) + { $tbluserroleroleid = mysqli_insert_id($conn); // Insert user authentication data into tbluserauth with hashed password - $sql1 = "INSERT INTO tbluserauth (username, password, tbluserroles_roleid) + $sql3 = "INSERT INTO tbluserauth (username, password, tbluserroles_roleid) VALUES ('$username', '$hashedPassword', $tbluserroleroleid)"; - $result1 = mysqli_query($conn, $sql1); + $result3 = mysqli_query($conn, $sql3); - if ($result1) { + if ($result3) + { header("Location: adminindex.php?msg=New record created successfully"); - } else { + } + else + { echo "Failed to insert user authentication data: " . mysqli_error($conn); } - } else { + } + else + { echo "Failed to insert user role data: " . mysqli_error($conn); } - } else { + } else + { echo "Failed to insert secretary data: " . mysqli_error($conn); } } + else if ($userpos == 'isDoc') + { + $sql = "INSERT INTO tbldoctor (fname, mname, lname, specialization, licensenum, phonenum, address) + VALUES ('$fname', '$mname', '$lname', '$specialization', '$licensenum', '$phonenum', '$address')"; + + $result = mysqli_query($conn, $sql); + + if ($result) + { + $doctorIDFK = mysqli_insert_id($conn); + $sql2 = "INSERT INTO tbluserroles (isDoc, doctorIDFK) VALUES (1, $doctorIDFK)"; + $result2 = mysqli_query($conn, $sql2); + if ($result2) + { + $tbluserroleroleid = mysqli_insert_id($conn); + // Insert user authentication data into tbluserauth with hashed password + $sql3 = "INSERT INTO tbluserauth (username, password, tbluserroles_roleid) + VALUES ('$username', '$hashedPassword', $tbluserroleroleid)"; + $result3 = mysqli_query($conn, $sql3); + + if ($result3) + { + header("Location: adminindex.php?msg=New record created successfully"); + } + else + { + echo "Failed to insert user authentication data: " . mysqli_error($conn); + } + } + else + { + echo "Failed to insert user role data: " . mysqli_error($conn); + } + } + else + { + echo "Failed to insert doctor data: " . mysqli_error($conn); + } + } } -} +} \ No newline at end of file