window.location.href="/Admin/View_AC?Type=Recurring"'; } $conn = new mysqli($GLOBALS['host'], $GLOBALS['user'], $GLOBALS['pass'], $GLOBALS['db']); $conn->set_charset("utf8"); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $user_id = $_POST['user_id']; $user_name = $_POST['user_name'] ?? ''; $user_phone = $_POST['user_phone'] ?? ''; $type = $_POST['type'] ?? 'agent'; $comiRate = $_POST['comi_rate'] ?? null; $passwordPlain = $_POST['password'] ?? ''; // Validation if (empty($user_name) || empty($user_phone) || empty($passwordPlain)) { $error = "All fields are required."; } elseif (!preg_match("/^[0-9]{10}$/", $user_phone)) { $error = "Invalid phone number format."; } else { $password = password_hash($passwordPlain, PASSWORD_DEFAULT); // Profile Picture Upload $profilePicPath = null; if (isset($_FILES['profile_pic']) && $_FILES['profile_pic']['error'] === UPLOAD_ERR_OK) { $uploadDir = __DIR__ . "/picture/"; if (!file_exists($uploadDir)) { mkdir($uploadDir, 0777, true); } $fileTmp = $_FILES['profile_pic']['tmp_name']; $fileName = time() . "_" . basename($_FILES['profile_pic']['name']); $filePath = $uploadDir . $fileName; if (move_uploaded_file($fileTmp, $filePath)) { $profilePicPath = "picture/" . $fileName; } else { $error = "Failed to upload profile picture."; } } if (!isset($error)) { $table = $GLOBALS['arif_users'] ?? 'arif_users'; $sql = "INSERT INTO `$table` (user_id, password, type, user_name, user_phone, comi_rate, profile_pic) VALUES (?, ?, ?, ?, ?, ?, ?)"; $stmt = $conn->prepare($sql); $stmt->bind_param("sssssss", $user_id, $password, $type, $user_name, $user_phone, $comiRate, $profilePicPath); if ($stmt->execute()) { $success = "User {$user_name} added successfully."; } else { $error = "Failed to add user: " . $stmt->error; } $stmt->close(); } } } $getAgentListsQuery = "SELECT * FROM " . $GLOBALS['arif_users'] . " ORDER BY type, user_id"; $agentResult = $conn->query($getAgentListsQuery); $agentList = []; if ($agentResult && $agentResult->num_rows > 0) { while ($row = $agentResult->fetch_assoc()) { $agentList[] = $row; } } ?>
| SL | Type | AC No | Name | Account Creation Date | Loan Amount | PHONE | Balance | Dedicated Agent | Dedicate an Agent |
|---|---|---|---|---|---|---|---|---|---|
| ".$tt." | ".$row["AA_ACTYPE"].",".$row["AA_TYPE"]." | ".$row["AA_ACNO"]." | ".$row["AA_NAME"]." | ".$row["AA_DATE"]." | ".$row["AA_MATURE_VALUE"]." | ".$row["AA_PHONE"]." | ".$row["AA_BAL"]. " | ".$row["AA_AGENT"].' |