/home/techb158/workloadmatch.com/workloadmatch.com/BackUp/Manager/Inc/AddUser.php (11841B)
Invalid password configuration.
'; header('Location: adduser.php?error=Invalid password configuration.'); exit(); } $random_salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE)); // Create salted password $Password = hash('sha512', $Password . $random_salt); do { $number_id = mt_rand(10000,999999); $prep_stmt = "SELECT AP.Admin_ID, MP.Master_ID, MGP.Manager_ID,BP.Teacher_ID,CP.Client_ID FROM admin_profile AP JOIN master_profile MP JOIN manager_profile MGP JOIN teacher_profile BP JOIN Client_Profile CP WHERE AP.Admin_ID=? OR MP.Master_ID=? OR MGP.Manager_ID=? OR BP.Teacher_ID=? OR CP.Client_ID=? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt){ $stmt->bind_param('sssss', $number_id, $number_id, $number_id, $number_id, $number_id); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { $count =$stmt->num_rows; // A user with this email address already exists //$error_msg .= 'A user with this user name already exists.
'; //header('Location: adduser.php?error=A user with this user name already exists.'); //exit(); } } } while ($count > 0); $prep_stmt = "SELECT Admin_ID FROM admin_profile WHERE User_Name = ? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt){ $stmt->bind_param('s', $User_Name); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { // A user with this email address already exists //$error_msg .= 'A user with this user name already exists.
'; header('Location: adduser.php?error=A user with this user name already exists.'); exit(); } }else{ // $error_msg .= 'Database error
'; } $prep_stmt = "SELECT Master_ID FROM master_profile WHERE User_Name = ? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt) { $stmt->bind_param('s', $User_Name); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { // A user with this email address already exists //$error_msg .= 'A user with this user name already exists.
'; header('Location: adduser.php?error=A user with this user name already exists.'); exit(); } } else { // $error_msg .= 'Database error
'; } $prep_stmt = "SELECT Manager_ID FROM manager_profile WHERE User_Name = ? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt) { $stmt->bind_param('s', $User_Name); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { // A user with this email address already exists //$error_msg .= 'A user with this user name already exists.
'; header('Location: adduser.php?error=A user with this user name already exists.'); exit(); } } else { //$error_msg .= 'Database error
'; } $prep_stmt = "SELECT Teacher_ID FROM teacher_profile WHERE User_Name = ? LIMIT 1"; $stmt = $mysqli->prepare($prep_stmt); if ($stmt) { $stmt->bind_param('s', $User_Name); $stmt->execute(); $stmt->store_result(); if ($stmt->num_rows == 1) { // A user with this email address already exists //$error_msg .= 'A user with this user name already exists.
'; header('Location: adduser.php?error=A user with this user name already exists.'); exit(); } } else { //$error_msg .= 'Database error
'; } $user_n=$_SESSION['user_id']; $querys = "SELECT * FROM manager_profile Where Manager_ID='".$user_n."'"; $results = $mysqli->query($querys); $rows = $results->fetch_assoc(); $Admin_ID = $rows['Admin_ID']; $Master_ID = $rows['Master_ID']; $Manager_ID = $rows['Manager_ID']; $Manager_ID_Profile = $rows['Manager_ID']; //$User_Type_ID = $rows['User_Type_ID']; $Manager_Email = $rows['Email']; $ManagerName = $rows['First_Name'] .' '. $rows['Last_Name']; $query = "SELECT * FROM teacher_profile Where User_Name ='".$User_Name."' AND Email ='".$Email."'"; $result = $mysqli->query($query); $Managers = $result->fetch_assoc(); $ID = $Managers['Teacher_ID']; if ($ID >= 1) { header('Location: adduser.php?error=User Name is already exist.'); exit(); }else{ //header('Location: adduser.php?error=User Name is already exist.'); //exit(); $User_Type_ID=3; $datetime =date("Y/m/d") . ' ' . date('H:i:s') ; $sql = "INSERT INTO teacher_profile ( Teacher_ID, Admin_ID, Master_ID, Manager_ID, User_Type_ID, Seniority_ID, First_Name, Last_Name, User_Name, Email, Phone, Password, salt, User_Access, Reg_Date, Login_Date, Logout_Date, prof_lang, Note, Load_Hours ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; if ($insert_stmt = $mysqli->prepare($sql)) { $insert_stmt->bind_param( 'ssssssssssssssssssss', $number_id, $Admin_ID, $Master_ID, $Manager_ID, $User_Type_ID, $Seniority_level, $First_Name, $Last_Name, $User_Name, $Email, $Phone, $Password, $random_salt, $User_Access, $datetime, $datetime, $datetime, $prof_lang, $Note, $Load_Hours ); if (!$insert_stmt->execute()) { header('Location: adduser.php?error=❌ Insert failed! ' . $insert_stmt->error); exit(); } // Insert restricted groups $insertionError = ''; if (isset($_POST['Restricted_Groups']) && is_array($_POST['Restricted_Groups'])) { $restrictedGroups = $_POST['Restricted_Groups']; $Teacher_ID = $number_id; // Step 2: Insert new restricted groups foreach ($restrictedGroups as $groupID) { $insertStmt = $mysqli->prepare("INSERT INTO Teacher_Restricted_Groups (Teacher_ID, Group_ID) VALUES (?, ?)"); $insertStmt->bind_param("ss", $Teacher_ID, $groupID); $insertStmt->execute(); $insertStmt->close(); } } // Redirect after group insert or general success header('Location: adduser.php?error=New User successfully registered!'); exit(); } else { header('Location: adduser.php?error=❌ Prepare failed! ' . $mysqli->error); exit(); } /* if ($insert_stmt = $mysqli->prepare("INSERT INTO teacher_profile (Teacher_ID, Admin_ID, Master_ID, Manager_ID, User_Type_ID, Seniority_ID, First_Name, Last_Name, User_Name, Email, Phone, Password, salt, User_Access, Reg_Date, Login_Date, Logout_Date,prof_lang,Note,Load_Hours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")) { //header('Location: adduser.php?error=file name already exists'.$user_n.''); $insert_stmt->bind_param('ssssssssssssssssssss',$number_id, $Admin_ID, $Master_ID, $Manager_ID, $User_Type_ID, $Seniority_level, $First_Name, $Last_Name, $User_Name, $Email, $Phone, $Password,$random_salt,$User_Access,$datetime, $datetime, $datetime, $prof_lang,$Note,$Load_Hours); // Execute the prepared query. if (! $insert_stmt->execute()) { //header('Location: adduser.php?error='.$insert_stmt->error); header('Location: adduser.php?error=Registration failure to add new User!'.$insert_stmt->error); //header('Location: addassist.php?error='.$Password.''); exit(); }else{ header('Location: adduser.php?error=New User successfully registered!'); exit(); //header('Location: adduser.php?error='.$mysqli->error); //exit(); } }else{ //header('Location: adduser.php?error='.$mysqli->error); //exit(); } } */ //header('Location: addclient.php?error='.$mysqli->error); } }else { header('Location: adduser.php?error=Registration failure please insert all informaion!'); exit(); } } // //$Teacher_ID= mysqli_insert_id($mysqli); // $Teacher_ID= $number_id; // //if(!empty($_POST["Access_Category"])) { // // $subject = "New Teacher Added"; // $uri = 'https://'. $_SERVER['HTTP_HOST'] ; // $message = ' // // //Dear "'.$UserName.'",
Your Account Details:
//User Name: "'.$User_Name.'"
//Please visit our login page Account Login.
"'."Thank you.".'"