prepare("INSERT INTO users (email, password, role) VALUES (?, ?, ?)"); $stmt->execute([$email, $password, $role]); $userId = (int)db()->lastInsertId(); if ($role === 'truck_owner') { $truckType = trim($_POST['truck_type'] ?? ''); $loadCapacity = trim($_POST['load_capacity'] ?? ''); $plateNo = trim($_POST['plate_no'] ?? ''); if ($truckType === '' || $loadCapacity === '' || $plateNo === '') { $errors[] = 'Please complete truck details.'; } elseif (!is_numeric($loadCapacity)) { $errors[] = 'Load capacity must be numeric.'; } if (!$errors) { $uploadDir = __DIR__ . '/uploads/profiles/' . $userId . '/'; if (!is_dir($uploadDir)) { mkdir($uploadDir, 0775, true); } $allowed = ['image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp']; $saveImage = static function (string $tmpName, string $prefix) use ($uploadDir, $allowed): ?string { $mime = mime_content_type($tmpName) ?: ''; if (!isset($allowed[$mime])) { return null; } $filename = uniqid($prefix, true) . '.' . $allowed[$mime]; $target = $uploadDir . $filename; if (!move_uploaded_file($tmpName, $target)) { return null; } return 'uploads/profiles/' . basename($uploadDir) . '/' . $filename; }; $idCardPaths = []; foreach (array_slice($_FILES['id_card']['tmp_name'] ?? [], 0, 2) as $tmp) { if (!is_uploaded_file($tmp)) { continue; } $path = $saveImage($tmp, 'id_'); if ($path) { $idCardPaths[] = $path; } } $regPaths = []; foreach (array_slice($_FILES['registration']['tmp_name'] ?? [], 0, 2) as $tmp) { if (!is_uploaded_file($tmp)) { continue; } $path = $saveImage($tmp, 'reg_'); if ($path) { $regPaths[] = $path; } } $truckPic = null; $truckTmp = $_FILES['truck_picture']['tmp_name'] ?? ''; if (is_uploaded_file($truckTmp)) { $truckPic = $saveImage($truckTmp, 'truck_'); } if (count($idCardPaths) < 2 || count($regPaths) < 2 || !$truckPic) { $errors[] = 'Please upload all required truck-owner images (ID front/back, registration front/back, truck photo).'; } else { $profileStmt = db()->prepare( "INSERT INTO truck_owner_profiles (user_id, truck_type, load_capacity, plate_no, id_card_path, truck_pic_path, registration_path) VALUES (?, ?, ?, ?, ?, ?, ?)" ); $profileStmt->execute([ $userId, $truckType, $loadCapacity, $plateNo, json_encode($idCardPaths, JSON_UNESCAPED_SLASHES), $truckPic, json_encode($regPaths, JSON_UNESCAPED_SLASHES), ]); } } } if (!$errors) { $saved = true; } } } render_header('Register Account'); ?>

Create account

Register as a shipper or truck owner using a clean onboarding form.

Registration completed successfully.
Back to admin