他們是一種集成 Drupal-8 和 ionic4 以進(jìn)行用戶注冊和登錄的方法嗎?
元芳怎么了
2021-12-03 19:08:00
我是 Drupal 8 的新手,我正在為我的公司做一個項(xiàng)目,請幫助解決這個問題。我們在 ionic 應(yīng)用程序中進(jìn)行了注冊,我們希望將數(shù)據(jù)發(fā)送到 Drupal 8 站點(diǎn) MySQL DB。問題是,當(dāng)我們在 Drupal 8 中使用多個注冊模塊創(chuàng)建注冊表時,會為表單中的每個字段創(chuàng)建一個單獨(dú)的表,例如數(shù)據(jù)庫中的用戶名字段有自己的表。我們?nèi)绾螌?yīng)用程序中的數(shù)據(jù)插入 Drupal DB 以允許用戶從應(yīng)用程序或網(wǎng)站注冊?我們在 Drupal 8 中使用多注冊模塊。我曾嘗試使用應(yīng)用程序內(nèi)瀏覽器 ( https://ionicframework.com/docs/native/in-app-browser ) 將表單嵌入我們的應(yīng)用程序中,但它顯示了我們不想要的帶有頁眉和頁腳的整個頁面.我還嘗試將數(shù)據(jù)作為 JSON 文件發(fā)送,并使用 PHP 和 MySQL 命令將數(shù)據(jù)插入表中,但這是一項(xiàng)非常漫長而艱巨的任務(wù)。let headers: any = new HttpHeaders({ 'Content-Type': 'application/json' }), options: any = { "key": "create", 'id': obj.id, 'fullName': obj.fullName, 'email': obj.email, 'idNumber': obj.idNumber, 'gender': obj.gender, 'age': obj.age, 'phone': obj.phone, 'status': obj.status, 'qualifications': obj.qualifications, 'skills': obj.skills[0], 'city': obj.city, 'terms': obj.terms, },this.http.post(url2, JSON.stringify(options), headers) .subscribe((data: any) => { console.log('successfully added'); }, (error: any) => { console.log('Something went wrong!', error); });并用于插入數(shù)據(jù)// Retrieve the posted data $json = file_get_contents('php://input'); $obj = json_decode($json); $key = strip_tags($obj->key); switch($key) { case "createTest": $field_mdynt_alskn_target_id = filter_var($obj->field_mdynt_alskn_target_id, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW); $field_username_value = filter_var($obj->field_altk_al_value, FILTER_SANITIZE_STRING, FILTER_FLAG_ENCODE_LOW); try { $sql = "INSERT INTO user_name(field_username_value) VALUES(:field_username_value)"; $stmt = $pdo->prepare($sql); $stmt->bindParam(':field_mdynt_alskn_target_id', $field_mdynt_alskn_target_id, PDO::PARAM_STR); $stmt->execute();這里的問題是每個字段在數(shù)據(jù)庫中都有自己的表,例如用戶名字段具有表 user_name 并且表單中的所有字段都相同,我對所有字段執(zhí)行相同的操作,我認(rèn)為這不是正確的方法。有沒有一種更快更有效的方法將我們 ionic 4 應(yīng)用程序注冊表中的數(shù)據(jù)插入到我們 Drupal 站點(diǎn)的數(shù)據(jù)庫中。謝謝你,以防萬一,讓我知道;需要進(jìn)一步澄清..
查看完整描述