diff --git a/Admin.php b/Admin.php index fd4dfbe..fedb051 100644 --- a/Admin.php +++ b/Admin.php @@ -66,7 +66,7 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") { ?> <form method="post" action="Script.php" id="create_account_form"> - <input type="hidden" name="form_createlecturrer" value="true" required="" /> + <input type="hidden" name="form_createlecturer" value="true" required="" /> Full name <input type="text" name="fullname" placeholder="Full Name" class="form-control" required=""> <br> Email @@ -93,10 +93,6 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") { echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION['info_Admin_Users'] . '</div>'; $_SESSION['info_Admin_Users'] = null; } - if (isset($_SESSION['info_Admin_Users'])) { - echo '<hr><div class="alert alert-warning" role="alert">' . $_SESSION['info_Admin_Users'] . '</div>'; - $_SESSION['info_Admin_Users'] = null; - } ?> </form> @@ -227,8 +223,22 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") { </div> + <?php include 'Footer.php';?> +<script> + /** After creating a TA account, stay on the same tab "Create instructor account" + Side effect: ?tacreated will be appended on the URL + */ + document.addEventListener("DOMContentLoaded", () => { + const url = new URL(window.location.href); + if (url.searchParams.has('tacreated')) { + const elem = document.querySelector('#tab_ins_accounts'); + elem.click(); + } + }); +</script> + <script> function updatePassword(id, pass) { if (!confirm('Are you sure to reset user password?')) { diff --git a/Script.php b/Script.php index 9329adc..5b6c92c 100644 --- a/Script.php +++ b/Script.php @@ -336,7 +336,7 @@ if (!empty($_POST["form_reset_password"])) { } // ############################### CREATE Lecturer/TA USER ################################## -if (!empty($_POST["form_createlecturrer"])){ +if (!empty($_POST["form_createlecturer"])){ $email = mysqli_real_escape_string($con, $_POST["email"]); $fullname = mysqli_real_escape_string($con, $_POST["fullname"]); $type = mysqli_real_escape_string($con, $_POST["type"]); @@ -361,7 +361,7 @@ if (!empty($_POST["form_createlecturrer"])){ try { $result = mysqli_query($con, $sql); $_SESSION["info_Admin_Users"] = $type . " user created successfully. Use email " . $email . " as account name and ". $password ." as password."; - header("Location: Admin.php"); + header("Location: Admin.php?tacreated"); } catch (Exception $ex) { echo "$ex"; }