Stay on the same tab after creating a new TA account
							parent
							
								
									aa82e9b5db
								
							
						
					
					
						commit
						545915b8be
					
				
							
								
								
									
										20
									
								
								Admin.php
								
								
								
								
							
							
						
						
									
										20
									
								
								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?')) { | ||||
|  |  | |||
|  | @ -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"; | ||||
|     } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue