{"id":1343,"date":"2022-11-28T08:58:10","date_gmt":"2022-11-28T00:58:10","guid":{"rendered":"https:\/\/hostscripter.com\/?p=1343"},"modified":"2022-11-28T08:58:10","modified_gmt":"2022-11-28T00:58:10","slug":"part-1-create-your-own-registration-system-using-php-and-mysql","status":"publish","type":"post","link":"https:\/\/hostscripter.com\/?p=1343","title":{"rendered":"Part 1: Create your own Registration System using PHP and MySql"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" class=\"featuredimage\" src=\"https:\/\/i0.wp.com\/codeshack.io\/web\/img\/posts\/secure-registration-system-php-mysql.png?resize=770%2C400&#038;ssl=1\" alt=\"Secure Registration System with PHP and MySQL\" width=\"770\" height=\"400\" data-recalc-dims=\"1\" \/><\/p>\n<div class=\"content m100 mpadtb\">\n<p>This tutorial is a follow up to our previous tutorial\u00a0<strong>Secure Login System with PHP and MySQL.<\/strong> In this tutorial, we&#8217;ll be creating a secure registration form and implementing basic validation.<\/p>\n<p>A registration form is what your website&#8217;s visitors can use to register their details, which will subsequently be stored in a MySQL database.<\/p>\n<h2 id=\"gettingstarted\">1. Getting Started<\/h2>\n<p>There are a few steps we need to take before we create our secure registration system. We need to set-up our web server environment and make sure we have the required extensions enabled\u00a0<i>(skip if you followed the secure login system tutorial)<\/i>.<\/p>\n<h3 id=\"requirements\">1.1. Requirements<\/h3>\n<ul>\n<li>If you haven&#8217;t got a local web server set-up, you will need to download and install\u00a0<a class=\"l1\" href=\"https:\/\/www.apachefriends.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">XAMPP<\/a>. XAMPP is a server-side web development environment that includes the essentials for back-end web developers.<\/li>\n<\/ul>\n<h3 id=\"whatyouwilllearn\">1.2. What You Will Learn in this Tutorial<\/h3>\n<ul>\n<li><b>Form Design<\/b>\u00a0\u2014 Design a registration form with HTML5 and CSS3.<\/li>\n<li><b>Prepared SQL Queries<\/b>\u00a0\u2014 How to prepare SQL queries to prevent SQL injection and insert new records into a MySQL database.<\/li>\n<li><b>Basic Validation<\/b>\u00a0\u2014 Validating form data that is sent to the server (username, password, and email).<\/li>\n<\/ul>\n<h3 id=\"filestructure\">1.3. File Structure &amp; Setup<\/h3>\n<p>We now need to start our web server and create the files and directories that we&#8217;re going to use for our registration system.<\/p>\n<ul>\n<li>Open\u00a0<i>XAMPP Control Panel<\/i><\/li>\n<li>Next to the Apache module click\u00a0<i>Start<\/i><\/li>\n<li>Next to the MySQL module click\u00a0<i>Start<\/i><\/li>\n<li>Navigate to XAMPPs installation folder (<i>C:\\xampp<\/i>)<\/li>\n<li>Open the\u00a0<i>htdocs<\/i>\u00a0folder<\/li>\n<li>Create the following folders and files:<\/li>\n<\/ul>\n<div class=\"contents fs\">\n<h2>File Structure<\/h2>\n<p>\\&#8211; phplogin<br \/>\n|&#8211; register.html<br \/>\n|&#8211; style.css<br \/>\n|&#8211; register.php<br \/>\n|&#8211; activate.php (optional)<\/p>\n<\/div>\n<p>Each file will contain the following:<\/p>\n<ul>\n<li><i>register.html<\/i>\u00a0\u2014 Registration form created with HTML5 and CSS3. As this file doesn&#8217;t require us to use PHP, we&#8217;ll save it as plain HTML.<\/li>\n<li><i>style.css<\/i>\u00a0\u2014 The stylesheet (CSS3) for our secure registration form.<\/li>\n<li><i>register.php<\/i>\u00a0\u2014 Validate form data and insert a new account into the MySQL database.<\/li>\n<li><i>activate.php<\/i>\u00a0\u2014 Activate the user&#8217;s account with a unique code (email based activation).<\/li>\n<\/ul>\n<\/div>\n<div data-counters='false' data-style='square' data-size='small' data-url='https:\/\/hostscripter.com\/?p=1343' data-title='Part 1: 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=1343' data-title='Part 1: 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>This tutorial is a follow up to our previous tutorial\u00a0Secure Login System with PHP and MySQL. In this tutorial, we&#8217;ll be creating a secure registration form and implementing basic validation. [&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-lF","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1329,"url":"https:\/\/hostscripter.com\/?p=1329","url_meta":{"origin":1343,"position":0},"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":1341,"url":"https:\/\/hostscripter.com\/?p=1341","url_meta":{"origin":1343,"position":1},"title":"Part 7: Create your own Login System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"7. Creating the Logout Script Creating the logout script is straightforward. All you need to do is destroy the sessions that were declared in the authenticate file. Edit the\u00a0logout.php\u00a0file and add the following code: <?php session_start(); session_destroy(); \/\/ Redirect to the login page: header('Location: index.html'); ?> Initialize sessions, destroy them,\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":1347,"url":"https:\/\/hostscripter.com\/?p=1347","url_meta":{"origin":1343,"position":2},"title":"Part 3: Create your own Registration System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"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, either using\u00a0phpMyAdmin\u00a0or your preferred MySQL database management application. If you're using\u00a0phpMyAdmin\u00a0then follow these instructions: Navigate to:\u00a0http:\/\/localhost\/phpmyadmin\/ Click the\u00a0Databases\u00a0tab at the\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":1354,"url":"https:\/\/hostscripter.com\/?p=1354","url_meta":{"origin":1343,"position":3},"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":1349,"url":"https:\/\/hostscripter.com\/?p=1349","url_meta":{"origin":1343,"position":4},"title":"Part 4: Create your own Registration System using PHP and MySql","author":"h05t5cr1pt3r","date":"November 28, 2022","format":false,"excerpt":"4. Registering Users with PHP & MySQL Now we need to create the registration file that will process the form fields, check for basic validation, and insert the new account into our database. The registration page will require a connection to our database and therefore we must include the necessary\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":1333,"url":"https:\/\/hostscripter.com\/?p=1333","url_meta":{"origin":1343,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1343"}],"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=1343"}],"version-history":[{"count":1,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1343\/revisions"}],"predecessor-version":[{"id":1344,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1343\/revisions\/1344"}],"wp:attachment":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}