{"id":1347,"date":"2022-11-28T09:02:03","date_gmt":"2022-11-28T01:02:03","guid":{"rendered":"https:\/\/hostscripter.com\/?p=1347"},"modified":"2022-11-28T09:02:03","modified_gmt":"2022-11-28T01:02:03","slug":"part-3-create-your-own-registration-system-using-php-and-mysql","status":"publish","type":"post","link":"https:\/\/hostscripter.com\/?p=1347","title":{"rendered":"Part 3: Create your own Registration System using PHP and MySql"},"content":{"rendered":"<h2 id=\"creatingthedatabaseandsettinguptables\">3. Creating the Database and setting-up Tables<\/h2>\n<p>You can skip this step if you followed the\u00a0<strong>Secure Login System Tutorial<\/strong>.<\/p>\n<p>For this part, you will need to access your MySQL database, either using\u00a0<a class=\"link1\" href=\"https:\/\/www.phpmyadmin.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">phpMyAdmin<\/a>\u00a0or your preferred MySQL database management application.<\/p>\n<p>If you&#8217;re using\u00a0<i>phpMyAdmin<\/i>\u00a0then follow these instructions:<\/p>\n<ul>\n<li>Navigate to:\u00a0<i>http:\/\/localhost\/phpmyadmin\/<\/i><\/li>\n<li>Click the\u00a0<i>Databases<\/i>\u00a0tab at the top<\/li>\n<li>Under\u00a0<i>Create database<\/i>, type in\u00a0<i>phplogin<\/i>\u00a0in the text box<\/li>\n<li>Select\u00a0<i>utf8_general_ci<\/i>\u00a0as the collation<\/li>\n<li>Click\u00a0<i>Create<\/i><\/li>\n<\/ul>\n<p>You can use your own database name, but for this tutorial, we&#8217;ll use\u00a0<i>phplogin<\/i>.<\/p>\n<p>What we need now is an\u00a0<i>accounts<\/i>\u00a0table that will store all our accounts (usernames, passwords, emails, etc).<\/p>\n<p>Click the database on the left side panel (<i>phplogin<\/i>) and execute the following SQL statement:<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-sql\"><code class=\" language-sql\"><span class=\"token keyword\">CREATE<\/span> <span class=\"token keyword\">TABLE<\/span> <span class=\"token keyword\">IF<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token keyword\">EXISTS<\/span> <span class=\"token punctuation\">`<\/span>accounts<span class=\"token punctuation\">`<\/span> <span class=\"token punctuation\">(<\/span>\r\n\t<span class=\"token punctuation\">`<\/span>id<span class=\"token punctuation\">`<\/span> <span class=\"token keyword\">int<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">11<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span> <span class=\"token keyword\">AUTO_INCREMENT<\/span><span class=\"token punctuation\">,<\/span>\r\n  \t<span class=\"token punctuation\">`<\/span>username<span class=\"token punctuation\">`<\/span> <span class=\"token keyword\">varchar<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">50<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span>\r\n  \t<span class=\"token punctuation\">`<\/span>password<span class=\"token punctuation\">`<\/span> <span class=\"token keyword\">varchar<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">255<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span>\r\n  \t<span class=\"token punctuation\">`<\/span>email<span class=\"token punctuation\">`<\/span> <span class=\"token keyword\">varchar<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">100<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">NOT<\/span> <span class=\"token boolean\">NULL<\/span><span class=\"token punctuation\">,<\/span>\r\n    <span class=\"token keyword\">PRIMARY<\/span> <span class=\"token keyword\">KEY<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">`<\/span>id<span class=\"token punctuation\">`<\/span><span class=\"token punctuation\">)<\/span>\r\n<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">ENGINE<\/span><span class=\"token operator\">=<\/span><span class=\"token keyword\">InnoDB<\/span> <span class=\"token keyword\">AUTO_INCREMENT<\/span><span class=\"token operator\">=<\/span><span class=\"token number\">2<\/span> <span class=\"token keyword\">DEFAULT<\/span> <span class=\"token keyword\">CHARSET<\/span><span class=\"token operator\">=<\/span>utf8<span class=\"token punctuation\">;<\/span><\/code><\/pre>\n<p>On\u00a0<i>phpMyAdmin<\/i>\u00a0this should look like:<\/p>\n<div class=\"browser\">\n<div><span class=\"url\">http:\/\/localhost\/phpmyadmin\/<\/span><\/div>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/phpmyadmin-accounts-table.png?resize=750%2C489&#038;ssl=1\" alt=\"phpMyAdmin Accounts Table\" width=\"750\" height=\"489\" data-recalc-dims=\"1\" \/><\/div>\n<p>The above SQL statement code will create the accounts table with the columns\u00a0<i class=\"hl\">id<\/i>,\u00a0<i class=\"hl\">username<\/i>,\u00a0<i class=\"hl\">password<\/i>, and\u00a0<i class=\"hl\">email<\/i>.<\/p>\n<div data-counters='false' data-style='square' data-size='small' data-url='https:\/\/hostscripter.com\/?p=1347' data-title='Part 3: Create your own Registration System using PHP and MySql' class='linksalpha_container linksalpha_app_3'><a href='\/\/www.linksalpha.com\/share?network='facebook' class='linksalpha_icon_facebook'><\/a><a href='\/\/www.linksalpha.com\/share?network='twitter' class='linksalpha_icon_twitter'><\/a><a href='\/\/www.linksalpha.com\/share?network='googleplus' class='linksalpha_icon_googleplus'><\/a><a href='\/\/www.linksalpha.com\/share?network='mail' class='linksalpha_icon_mail'><\/a><\/div><div data-position='' data-url='https:\/\/hostscripter.com\/?p=1347' data-title='Part 3: Create your own Registration System using PHP and MySql' class='linksalpha_container linksalpha_app_7'><a href='\/\/www.linksalpha.com\/share?network='facebook' class='linksalpha_icon_facebook'><\/a><a href='\/\/www.linksalpha.com\/share?network='twitter' class='linksalpha_icon_twitter'><\/a><a href='\/\/www.linksalpha.com\/share?network='googleplus' class='linksalpha_icon_googleplus'><\/a><a href='\/\/www.linksalpha.com\/share?network='mail' class='linksalpha_icon_mail'><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>3. Creating the Database and setting-up Tables You can skip this step if you followed the\u00a0Secure Login System Tutorial. For this part, you will need to access your MySQL database, [&hellip;]<\/p>\n","protected":false},"author":301,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[4],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9KaPo-lJ","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1333,"url":"https:\/\/hostscripter.com\/?p=1333","url_meta":{"origin":1347,"position":0},"title":"Part 3: Create your own Login System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"3. Creating the Database and setting-up Tables For this part, you will need to access your MySQL database, either using\u00a0phpMyAdmin\u00a0or your preferred MySQL database management application. Follow the below instructions if you're using\u00a0phpMyAdmin. Navigate to:\u00a0http:\/\/localhost\/phpmyadmin\/ Click the\u00a0Databases\u00a0tab at the top Under\u00a0Create database, enter\u00a0phplogin\u00a0in the text box Select\u00a0utf8_general_ci\u00a0as the collation Click\u00a0Create\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/hostscripter.com\/?cat=4"},"img":{"alt_text":"phpMyAdmin Accounts Table","src":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/phpmyadmin-accounts-table.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/phpmyadmin-accounts-table.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/phpmyadmin-accounts-table.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/phpmyadmin-accounts-table.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1329,"url":"https:\/\/hostscripter.com\/?p=1329","url_meta":{"origin":1347,"position":1},"title":"Part 1: Create your own Login System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"In this tutorial, I'll be teaching you how you can create your very own secure PHP login system. A login form is what your website's visitors can use to log in to your website to access restricted content, such as a profile page. We will leverage MySQL to retrieve account\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/hostscripter.com\/?cat=4"},"img":{"alt_text":"Secure Login System with PHP and MySQL","src":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-login-system-php-mysql.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-login-system-php-mysql.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-login-system-php-mysql.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-login-system-php-mysql.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1354,"url":"https:\/\/hostscripter.com\/?p=1354","url_meta":{"origin":1347,"position":2},"title":"Part 6: Create your own Registration System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"6. Implementing Account Activation The account activation system will send an email to the user with the activation link when the user has registered. The first thing we need to do is to go into\u00a0phpMyAdmin\u00a0and select our database, in our case this would be\u00a0phplogin, you can either add the column\u00a0activation_code\u00a0to\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/hostscripter.com\/?cat=4"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1343,"url":"https:\/\/hostscripter.com\/?p=1343","url_meta":{"origin":1347,"position":3},"title":"Part 1: Create your own Registration System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"This tutorial is a follow up to our previous tutorial\u00a0Secure Login System with PHP and MySQL. In this tutorial, we'll be creating a secure registration form and implementing basic validation. A registration form is what your website's visitors can use to register their details, which will subsequently be stored in\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/hostscripter.com\/?cat=4"},"img":{"alt_text":"Secure Registration System with PHP and MySQL","src":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-registration-system-php-mysql.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-registration-system-php-mysql.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-registration-system-php-mysql.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-registration-system-php-mysql.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1335,"url":"https:\/\/hostscripter.com\/?p=1335","url_meta":{"origin":1347,"position":4},"title":"Part 4: Create your own Login System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"4. Authenticating Users with PHP Now that we have our database setup, we can go ahead and start coding with PHP. We're going to start with the authentication file, which will process and validate the form data that we'll send from our\u00a0index.html\u00a0file. Edit the\u00a0authenticate.php\u00a0file and add the following: <?php session_start();\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/hostscripter.com\/?cat=4"},"img":{"alt_text":"Authentication Incorrect Username PHP","src":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/authentication-incorrect-username.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/authentication-incorrect-username.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/authentication-incorrect-username.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/authentication-incorrect-username.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1339,"url":"https:\/\/hostscripter.com\/?p=1339","url_meta":{"origin":1347,"position":5},"title":"Part 6: Create your own Login System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"6. Creating the Profile Page The profile page will display the account information for the logged-in user. Edit the\u00a0profile.php\u00a0file and add the following code: <?php \/\/ We need to use sessions, so you should always start sessions using the below code. session_start(); \/\/ If the user is not logged in\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/hostscripter.com\/?cat=4"},"img":{"alt_text":"PHP Loggedin Profile Page","src":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/loggedin-profile-page.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/loggedin-profile-page.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/loggedin-profile-page.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/codeshack.io\/web\/img\/phplogin\/loggedin-profile-page.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1347"}],"collection":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/users\/301"}],"replies":[{"embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1347"}],"version-history":[{"count":1,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1347\/revisions"}],"predecessor-version":[{"id":1348,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1347\/revisions\/1348"}],"wp:attachment":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}