{"id":9411,"date":"2020-01-24T13:01:37","date_gmt":"2020-01-24T13:01:37","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=9411"},"modified":"2020-01-24T13:03:03","modified_gmt":"2020-01-24T13:03:03","slug":"user-registration-using-nodejs-and-mysql-with-example","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/user-registration-using-nodejs-and-mysql-with-example\/","title":{"rendered":"User registration using nodejs and mysql with example"},"content":{"rendered":"\n<p> In this tutorial, I am going to create simple register a user and display the data on dashboard using nodejs and mysql.<br>This tutorial will explain only how to save a record in mysql table and display the table.<br>To handle post parameters of Http request in Node.js, we use CrudApp module. <\/p>\n\n\n\n<p> <strong>step-1<\/strong> First we install express-generator using npm through command line. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"985\" height=\"100\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/express-generator-1.png\" alt=\"\" class=\"wp-image-9412\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/express-generator-1.png 985w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/express-generator-1-300x30.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/express-generator-1-768x78.png 768w\" sizes=\"auto, (max-width: 985px) 100vw, 985px\" \/><\/figure>\n\n\n\n<p> <strong>step-2<\/strong> Then we install crudapp . &#8216;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"980\" height=\"170\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp.png\" alt=\"\" class=\"wp-image-9415\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp.png 980w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp-300x52.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp-768x133.png 768w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"976\" height=\"516\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp2.png\" alt=\"\" class=\"wp-image-9417\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp2.png 976w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp2-300x159.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/crudapp2-768x406.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/figure>\n\n\n\n<p> <strong>step-3<\/strong> Then we go to the crudapp directory and install npm <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"982\" height=\"369\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/npm-install2.png\" alt=\"\" class=\"wp-image-9424\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/npm-install2.png 982w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/npm-install2-300x113.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/npm-install2-768x289.png 768w\" sizes=\"auto, (max-width: 982px) 100vw, 982px\" \/><\/figure>\n\n\n\n<p> <strong>step-4<\/strong> Then we uninstalled Jade App(Jade App is inbuild App in Crudapp for execute html files).<br>we installed express-handlebars App for executing html files. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"368\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-express-handlebars.png\" alt=\"\" class=\"wp-image-9426\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-express-handlebars.png 979w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-express-handlebars-300x113.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-express-handlebars-768x289.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/figure>\n\n\n\n<p> <strong>step-5<\/strong> Then we installed mysql using npm. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"982\" height=\"366\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-mysql.png\" alt=\"\" class=\"wp-image-9430\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-mysql.png 982w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-mysql-300x112.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/install-mysql-768x286.png 768w\" sizes=\"auto, (max-width: 982px) 100vw, 982px\" \/><\/figure>\n\n\n\n<p> <strong>step<\/strong>&#8211;<strong>6<\/strong> Then we create crudapp database and users table in phpmyadmin <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/database-1024x370.png\" alt=\"\" class=\"wp-image-9435\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/database-1024x370.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/database-300x109.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/database-768x278.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2020\/01\/database.png 1313w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p> <strong>step-7 <\/strong>Then we create Connection.js file for connection with mysql database. <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/80bc2e0487e7f8e5e34bf46690a8c2fa.js\"><\/script>\n\n\n\n<p> <strong>step-8<\/strong> Modified app.js files for adding our required code. <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/51418f9b25d23d572dd65390d78343e1.js\"><\/script>\n\n\n\n<p> <strong>step-9<\/strong> Create a routes directory and in routes directory create index.js and users.js files. <\/p>\n\n\n\n<p> <strong>step-10<\/strong> index.js file add these codes. <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/352f01402eaab93cd61fffd72a8e3e8e.js\"><\/script>\n\n\n\n<p> <strong>step-11<\/strong> users.js file add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/1d3516f091220cd5e92ad937ddd692e0.js\"><\/script>\n\n\n\n<p> <strong>step-12<\/strong>&nbsp;Create a public directory and in public directory create js and css directories.<br><strong>step-13<\/strong>&nbsp;In js directory add angular.min.js, index.js, jquery.easing.min.js, jquery-1.9.1.min.js and script.js files.<br><strong>step-14 <\/strong>angular.min.js file add these codes.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/94fe367809ea6f27c2651f408feb107d.js\"><\/script>\n\n\n\n<p> <strong>step-15<\/strong> Index.js file add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/c83161bbd4d35037db03509160f720e9.js\"><\/script>\n\n\n\n<p> <strong>step-16 <\/strong>jquery.easing.min.js file add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/c34ec2d383ca812728f56c45143ea681.js\"><\/script>\n\n\n\n<p> <strong>step-17 <\/strong>jquery-1.9.1.min.js file add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/25525c30a2f14a946dc6547c0741064d.js\"><\/script>\n\n\n\n<p><strong>step-18 <\/strong>script.js files. file add these codes<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/5b0511d1e0f04a96370b837ed04a0bcf.js\"><\/script>\n\n\n\n<p> <strong>step-19<\/strong>&nbsp;In css directory add reset.min.css and style.css <\/p>\n\n\n\n<p> <strong>step-20<\/strong>&nbsp;In reset.min.css add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/8fb368bf030e6dcea5e85be30dcf831b.js\"><\/script>\n\n\n\n<p> <strong>step-21<\/strong>&nbsp;In style.css add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/042de83d451d212820296c9aacb7f785.js\"><\/script>\n\n\n\n<p> <strong>step-22<\/strong>&nbsp;Create views directory and in views directory create layout.hbs, index.hbs and dashboard.hbs and also add js and css files. <\/p>\n\n\n\n<p> <strong>step-23<\/strong>&nbsp;In layout.hbs add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/03a79402b1f23c2e37ab3a429045bc4a.js\"><\/script>\n\n\n\n<p> <strong>step-24<\/strong>&nbsp;In index.hbs add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/5642cdcc8a53a11290d0c9285df4d3d1.js\"><\/script>\n\n\n\n<p> <strong>step-25<\/strong>&nbsp;In dashboard.hbs add these codes <\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/amardeep18\/d4c1a523147cdc63c6dd5c49933479c8.js\"><\/script>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, I am going to create simple register a user and display the data on dashboard using nodejs and mysql.This tutorial will explain only how to save a&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5830],"tags":[],"class_list":["post-9411","post","type-post","status-publish","format-standard","hentry","category-node-js"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=9411"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9411\/revisions"}],"predecessor-version":[{"id":9525,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/9411\/revisions\/9525"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=9411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=9411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=9411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}