connect_error) die("Connection failed: " . $conn->connect_error); $categories_master = [ "Regularization - 2 Months", "Terminal Benefits(Leave Encashment, Gratuity) - 3 Months", "MACP/ACP - 1 Month", "Salary Slip - 1 Day", "Pension - 3 Months", "Compassionate Ground - 3 Months", "Form 16 - 10 Days", "Mobile Attendance - 2 Days", "Medical Reimbursement - 30 Days", "NPS - 10 Days", "NPS to OPS - 2 Months", "BMID Creation - 2 Days" ]; $roles = ["DDO", "AO", "SO", "EC/BC"]; $departments = [ 1 => 'ATR', 2 => 'ARC', 3 => 'AYU', 4 => 'CED', 5 => 'CZO', 6 => 'COM', 7 => 'CSD', 8 => 'DMT', 9 => 'EDU', 10 => 'EGN', 11 => 'EMS', 12 => 'FLD', 13 => 'FIN', 14 => 'HOR', 15 => 'HHA', 16 => 'IT', 17 => 'LW', 18 => 'LNE', 19 => 'LAN', 20 => 'LAW', 21 => 'MCA', 22 => 'MSO', 23 => 'PNI', 24 => 'PNS', 25 => 'PTAC', 26 => 'PH', 27 => 'TT', 28 => 'TP', 29 => 'VS', 30 => 'VGL' ]; if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["add_user"])) { $user_name = $_POST["user_name"]; $department = $_POST["department"]; $role = $_POST["role"]; $location = $_POST["location"]; $location_prefix = ($location == "zone") ? "ZN" : "HQ"; $user_id = "$location_prefix." . $departments[$department] . "." . $role; $sql = "INSERT INTO users (user_name, user_id, department, role, location) VALUES ('$user_name', '$user_id', '$department', '$role', '$location')"; $conn->query($sql); echo "User added successfully."; } ?>
User:
Role:
| User ID | Name | Department | Role | Location |
|---|---|---|---|---|
| {$row['user_id']} | {$row['user_name']} | {$departments[$row['department']]} | {$row['role']} | {$row['location']} |
Total Users: query("SELECT COUNT(*) as count FROM users")->fetch_assoc()['count']; ?>