{"id":236,"date":"2017-09-17T21:32:52","date_gmt":"2017-09-17T16:02:52","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=236"},"modified":"2017-10-14T13:08:00","modified_gmt":"2017-10-14T07:38:00","slug":"create-custom-registration-form-native-app-using-ionic-framework-php-backend","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/","title":{"rendered":"How to create a custom registration form for native app using Ionic framework and PHP (for backend)"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>In this article we are going to build a simple registration form by using Ionic framework for front end and core Php for back end<\/p>\n<h5><strong>Step 1<\/strong><\/h5>\n<p>Install <em><strong><a href=\"https:\/\/ionicframework.com\/getting-started\/\">Ionic Cordova<\/a><\/strong><\/em>. If you have done it already, skip this step.<\/p>\n<h5><strong>Step 2<\/strong><\/h5>\n<p><em>app.module.ts<\/em><\/p>\n<p>Import http module as we will use http post method in our form and import reactive form module as we will use reactive form in our app.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-237\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step2.png\" alt=\"Step 2\" width=\"718\" height=\"515\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step2.png 718w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step2-300x215.png 300w\" sizes=\"(max-width: 718px) 100vw, 718px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong>Step 3<\/strong><\/h5>\n<p><em>home.html<\/em><\/p>\n<p>We will create our registration form here in reactive form format and validate them using reactive method. In our form there will be four fields (name, email, password, confirm password). Submit button will\u00a0 be disabled if form is invalid and after submit we will call a function registerToApp()<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-238\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step3.png\" alt=\"Step 3\" width=\"869\" height=\"729\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step3.png 869w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step3-300x252.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step3-768x644.png 768w\" sizes=\"(max-width: 869px) 100vw, 869px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong>Step 4<\/strong><\/h5>\n<p><em>home.ts<\/em><\/p>\n<p>Import formbuilder, validators, http, response, header, rxjs map. And next we will declare them in constructor.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-239\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step4-1.png\" alt=\"Step 4.1\" width=\"796\" height=\"362\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-1.png 796w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-1-300x136.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-1-768x349.png 768w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>In this file we have to create our form validation rules here for specific fields of our registration form in reactive form builder module<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-240\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step4-2.png\" alt=\"Step 4.2\" width=\"786\" height=\"128\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-2.png 786w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-2-300x49.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-2-768x125.png 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>We must have to define the submit function registerToApp here<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-241\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step4-3.png\" alt=\"Step 4.3\" width=\"318\" height=\"60\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-3.png 318w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step4-3-300x57.png 300w\" sizes=\"(max-width: 318px) 100vw, 318px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>As\u00a0we want to make our code clean, we will create a separate service for registration. We will create a folder service within &#8220;src&#8221; folder and within that service folder we will create registration.service.ts file.<\/em><\/strong><\/p>\n<h5><strong>Step 5<\/strong><\/h5>\n<p><em>registration.service.ts<\/em><\/p>\n<p>We will import all the necessary files to create our own service and as we are going to inject this service we have to define this service as injectable<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-242\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step5-1.png\" alt=\"Step 5.1\" width=\"778\" height=\"187\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step5-1.png 778w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step5-1-300x72.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step5-1-768x185.png 768w\" sizes=\"(max-width: 778px) 100vw, 778px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>We will define a function here doRegister(), within this function we will define headers and Create a http post method to insert data into database by insert_data.php which we will create in the next step. In this function \u00a0First parameter\u00a0 will be the exact path of that php file from localhost if using xampp and this function will return an output\u00a0 from that php file which we will hold in \u2018res\u2019 variable and we will do mapping to get the results in json format<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-243\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step5-2.png\" alt=\"Step 5.2\" width=\"783\" height=\"244\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step5-2.png 783w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step5-2-300x93.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step5-2-768x239.png 768w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong><em>Let\u00a0us create a file within &#8220;src &gt; assets&#8221; folder and named it as insert_data.php<\/em><\/strong><\/p>\n<h5><strong>Step 6<\/strong><\/h5>\n<p><em>insert_data.php<\/em><\/p>\n<p>Here we will assign our form values to php variables and We will connect to our database registration and run mysql query to insert data to table called registered_members by using simple php code here<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-251\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/database.png\" alt=\"database\" width=\"239\" height=\"78\" \/><\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-252\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/database-table.png\" alt=\"database table\" width=\"878\" height=\"150\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/database-table.png 878w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/database-table-300x51.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/database-table-768x131.png 768w\" sizes=\"(max-width: 878px) 100vw, 878px\" \/><\/p>\n<p>In both the cases(failed or success) it will return a json encoded array&#8230; if we return only text here it will return an json parse error every time in our console<\/p>\n<p>Here we are using a simple cheking. That is if an email which is entered in that registration form is already exist, it will show an error message.<\/p>\n<p>If everything is alright the Then insert the values into the database.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-244\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step6.png\" alt=\"Step 6\" width=\"770\" height=\"638\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step6.png 770w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step6-300x249.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step6-768x636.png 768w\" sizes=\"(max-width: 770px) 100vw, 770px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong>Step 7<\/strong><\/h5>\n<p><em>Return to app.module.ts<\/em><\/p>\n<p>Import that service we have just created in this file so that we can access it anywhere<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-245\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step7.png\" alt=\"Step 7\" width=\"760\" height=\"204\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step7.png 760w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step7-300x81.png 300w\" sizes=\"(max-width: 760px) 100vw, 760px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong>Step 8<\/strong><\/h5>\n<p><em>go back to home.ts<\/em><\/p>\n<p>Import registration.service.ts and declare it in constructor<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-255\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step8-1.png\" alt=\"Step8.1\" width=\"792\" height=\"70\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step8-1.png 792w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step8-1-300x27.png 300w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step8-1-768x68.png 768w\" sizes=\"(max-width: 792px) 100vw, 792px\" \/><\/p>\n<p>Within the function named registerToApp() we will run our registration service and subscribe the returned values so that we can view if the values are submitted properly or not. if success then it will return a success function along with insertion of those data into database.<\/p>\n<p><img loading=\"lazy\" class=\"alignnone size-full wp-image-256\" src=\"http:\/\/blog.openwebsolutions.in\/wp-content\/uploads\/2017\/09\/step8-2.png\" alt=\"Step8.2\" width=\"683\" height=\"504\" srcset=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step8-2.png 683w, https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/step8-2-300x221.png 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><\/p>\n<p><strong>That&#8217;s all. You have created a simple registration form using Ionic and Php.<\/strong><\/p>\n<p>You can view the full project on <em><strong><a href=\"https:\/\/github.com\/PreetamMallick\/ionic_login_register_with_manual_otp_verification\">Github\u00a0<\/a><\/strong><\/em><\/p>\n<p>Follow me on\u00a0<a href=\"https:\/\/www.linkedin.com\/in\/preetam-mallick-84321254\/\"><em><strong>LinkedIn<\/strong><\/em><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; In this article we are going to build a simple registration form by using Ionic framework for front end and core Php for back end Step 1 Install Ionic Cordova. If you have done it already, skip this step. Step 2 app.module.ts Import http module as we will use http post method in our [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":247,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[12,3],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create a custom registration form for native app using Ionic framework and PHP (Backend)<\/title>\n<meta name=\"description\" content=\"In this article we are going to build a simple registration form by using Ionic framework for front end and core Php for back end\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a custom registration form for native app using Ionic framework and PHP (Backend)\" \/>\n<meta property=\"og:description\" content=\"In this article we are going to build a simple registration form by using Ionic framework for front end and core Php for back end\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-17T16:02:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-10-14T07:38:00+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/create-registration-app-by-ionic.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"497\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2017\/09\/create-registration-app-by-ionic.jpg\",\"width\":1024,\"height\":497,\"caption\":\"create registration app by ionic\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/\",\"name\":\"How to create a custom registration form for native app using Ionic framework and PHP (Backend)\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/#primaryimage\"},\"datePublished\":\"2017-09-17T16:02:52+00:00\",\"dateModified\":\"2017-10-14T07:38:00+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\"},\"description\":\"In this article we are going to build a simple registration form by using Ionic framework for front end and core Php for back end\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/create-custom-registration-form-native-app-using-ionic-framework-php-backend\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\",\"name\":\"Preetam Mallick\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed836329485e177373e4ff5323b6670a?s=96&r=g\",\"caption\":\"Preetam Mallick\"},\"description\":\"Frontend developer at Openweb Solutions\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/236"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=236"}],"version-history":[{"count":8,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions"}],"predecessor-version":[{"id":286,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/236\/revisions\/286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/247"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}