{"id":1354,"date":"2022-11-28T09:10:16","date_gmt":"2022-11-28T01:10:16","guid":{"rendered":"https:\/\/hostscripter.com\/?p=1354"},"modified":"2022-11-28T09:10:16","modified_gmt":"2022-11-28T01:10:16","slug":"part-6-create-your-own-registration-system-using-php-and-mysql","status":"publish","type":"post","link":"https:\/\/hostscripter.com\/?p=1354","title":{"rendered":"Part 6: Create your own Registration System using PHP and MySql"},"content":{"rendered":"<h2 id=\"implementingaccountactivation\">6. Implementing Account Activation<\/h2>\n<p>The account activation system will send an email to the user with the activation link when the user has registered.<\/p>\n<p>The first thing we need to do is to go into\u00a0<i>phpMyAdmin<\/i>\u00a0and select our database, in our case this would be\u00a0<i>phplogin<\/i>, you can either add the column\u00a0<i class=\"hl\">activation_code<\/i>\u00a0to the accounts table or execute the SQL statement below.<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-sql\"><code class=\" language-sql\"><span class=\"token keyword\">ALTER<\/span> <span class=\"token keyword\">TABLE<\/span> accounts <span class=\"token keyword\">ADD<\/span> activation_code <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 keyword\">DEFAULT<\/span> <span class=\"token string\">''<\/span><\/code><\/pre>\n<p>Now we need to edit our\u00a0<i>register.php<\/i>\u00a0file, search for this line of code:<\/p>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$stmt<\/span> <span class=\"token operator\">=<\/span> <span class=\"token variable\">$con<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'INSERT INTO accounts (username, password, email) VALUES (?, ?, ?)'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/code><\/pre>\n<p>Replace with:<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$stmt<\/span> <span class=\"token operator\">=<\/span> <span class=\"token variable\">$con<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'INSERT INTO accounts (username, password, email, activation_code) VALUES (?, ?, ?, ?)'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><\/code><\/pre>\n<p>Search for:<\/p>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">bind_param<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'sss'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_POST<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'username'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$password<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_POST<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/code><\/pre>\n<p>Replace with:<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token variable\">$uniqid<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">uniqid<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">bind_param<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'ssss'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_POST<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'username'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$password<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_POST<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$uniqid<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n<\/code><\/pre>\n<p>The\u00a0<i class=\"hl\">$uniqud<\/i>\u00a0variable will generate a unique ID that we&#8217;ll use for our activation code, this will be sent to the user&#8217;s email address.<\/p>\n<p>Search for:<\/p>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token keyword\">echo<\/span> <span class=\"token string\">'You have successfully registered, you can now login!'<\/span><span class=\"token punctuation\">;<\/span><\/code><\/pre>\n<p>Replace with:<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token variable\">$from<\/span>    <span class=\"token operator\">=<\/span> <span class=\"token string\">'noreply@yourdomain.com'<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$subject<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'Account Activation Required'<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$headers<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'From: '<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token variable\">$from<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">\"\\r\\n\"<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'Reply-To: '<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token variable\">$from<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">\"\\r\\n\"<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'X-Mailer: PHP\/'<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token function\">phpversion<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">\"\\r\\n\"<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'MIME-Version: 1.0'<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">\"\\r\\n\"<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'Content-Type: text\/html; charset=UTF-8'<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">\"\\r\\n\"<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token comment\">\/\/ Update the activation variable below<\/span>\r\n<span class=\"token variable\">$activate_link<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'http:\/\/yourdomain.com\/phplogin\/activate.php?email='<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token global\">$_POST<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'&amp;code='<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token variable\">$uniqid<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$message<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'&lt;p&gt;Please click the following link to activate your account: &lt;a href=\"'<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token variable\">$activate_link<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'\"&gt;'<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token variable\">$activate_link<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token string\">'&lt;\/a&gt;&lt;\/p&gt;'<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token function\">mail<\/span><span class=\"token punctuation\">(<\/span><span class=\"token global\">$_POST<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$subject<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$message<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$headers<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token keyword\">echo<\/span> <span class=\"token string\">'Please check your email to activate your account!'<\/span><span class=\"token punctuation\">;<\/span><\/code><\/pre>\n<p>Upon account registration, the user will need to activate their account using the activation link that is sent to their email address. You need to update both the\u00a0<i class=\"hl\">$from<\/i>\u00a0and\u00a0<i class=\"hl\">$activate_link<\/i>\u00a0variables.<\/p>\n<p>Now we can proceed to create the activation file. The activation file will process the GET parameters and verify the email and code. The user&#8217;s account will be activated if the code is valid.<\/p>\n<p>Edit\/create the\u00a0<i>activate.php<\/i>\u00a0file and add the following code:<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token php language-php\"><span class=\"token delimiter important\">&lt;?php<\/span>\r\n<span class=\"token comment\">\/\/ Change this to your connection info.<\/span>\r\n<span class=\"token variable\">$DATABASE_HOST<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'localhost'<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$DATABASE_USER<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'root'<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$DATABASE_PASS<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">''<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token variable\">$DATABASE_NAME<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'phplogin'<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token comment\">\/\/ Try and connect using the info above.<\/span>\r\n<span class=\"token variable\">$con<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">mysqli_connect<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$DATABASE_HOST<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$DATABASE_USER<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$DATABASE_PASS<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$DATABASE_NAME<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">mysqli_connect_errno<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t<span class=\"token comment\">\/\/ If there is an error with the connection, stop the script and display the error.<\/span>\r\n\t<span class=\"token function\">exit<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'Failed to connect to MySQL: '<\/span> <span class=\"token punctuation\">.<\/span> <span class=\"token function\">mysqli_connect_error<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token comment\">\/\/ First we check if the email and code exists...<\/span>\r\n<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token function\">isset<\/span><span class=\"token punctuation\">(<\/span><span class=\"token global\">$_GET<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_GET<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'code'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$stmt<\/span> <span class=\"token operator\">=<\/span> <span class=\"token variable\">$con<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'SELECT * FROM accounts WHERE email = ? AND activation_code = ?'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t\t<span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">bind_param<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'ss'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_GET<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_GET<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'code'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t<span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">execute<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t<span class=\"token comment\">\/\/ Store the result so we can check if the account exists in the database.<\/span>\r\n\t\t<span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">store_result<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token property\">num_rows<\/span> <span class=\"token operator\">&gt;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t\t\t<span class=\"token comment\">\/\/ Account exists with the requested email and code.<\/span>\r\n\t\t\t<span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$stmt<\/span> <span class=\"token operator\">=<\/span> <span class=\"token variable\">$con<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">prepare<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'UPDATE accounts SET activation_code = ? WHERE email = ? AND activation_code = ?'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t\t\t\t<span class=\"token comment\">\/\/ Set the new activation code to 'activated', this is how we can check if the user has activated their account.<\/span>\r\n\t\t\t\t<span class=\"token variable\">$newcode<\/span> <span class=\"token operator\">=<\/span> <span class=\"token string\">'activated'<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t\t\t<span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">bind_param<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">'sss'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$newcode<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_GET<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'email'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token global\">$_GET<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'code'<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t\t\t<span class=\"token variable\">$stmt<\/span><span class=\"token operator\">-<\/span><span class=\"token operator\">&gt;<\/span><span class=\"token function\">execute<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t\t\t<span class=\"token keyword\">echo<\/span> <span class=\"token string\">'Your account is now activated! You can now &lt;a href=\"index.html\"&gt;login&lt;\/a&gt;!'<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t\t<span class=\"token punctuation\">}<\/span>\r\n\t\t<span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t\t\t<span class=\"token keyword\">echo<\/span> <span class=\"token string\">'The account is already activated or doesn\\'t exist!'<\/span><span class=\"token punctuation\">;<\/span>\r\n\t\t<span class=\"token punctuation\">}<\/span>\r\n\t<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token delimiter important\">?&gt;<\/span><\/span><\/code><\/pre>\n<p>If the code reflects the one in the database that is associated with the user&#8217;s account then the value of the\u00a0<i class=\"hl\">activation_code<\/i>\u00a0column will be updated to\u00a0<i class=\"hl\">activated<\/i>.<\/p>\n<p>If we want to check if the user has activated their account, we can add the following code to the pages we want to restrict non-activated users:<\/p>\n<div class=\"code-header\"><\/div>\n<pre class=\" language-php\"><code class=\" language-php\"><span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token variable\">$account<\/span><span class=\"token punctuation\">[<\/span><span class=\"token string\">'activation_code'<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">==<\/span> <span class=\"token string\">'activated'<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t<span class=\"token comment\">\/\/ account is activated<\/span>\r\n\t<span class=\"token comment\">\/\/ Display home page etc<\/span>\r\n<span class=\"token punctuation\">}<\/span> <span class=\"token keyword\">else<\/span> <span class=\"token punctuation\">{<\/span>\r\n\t<span class=\"token comment\">\/\/ account is not activated<\/span>\r\n\t<span class=\"token comment\">\/\/ redirect user or display an error<\/span>\r\n<span class=\"token punctuation\">}<\/span><\/code><\/pre>\n<p>For the above code to work, you will need to connect to your MySQL database and select the user&#8217;s account.<\/p>\n<p>Also, take note PHP mail function will only work if your computer or server supports it. If it doesn&#8217;t send an email, check your configuration or install a mail server such as\u00a0<a class=\"l1\" href=\"http:\/\/www.postfix.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Postfix<\/a>.<\/p>\n<h2>Conclusion<\/h2>\n<p>Congratulations! You&#8217;ve successfully created a\u00a0<strong>Login System<\/strong>\u00a0(if you followed the previous tutorial) and registration system with PHP and MySQL. You&#8217;re free to use the code in this tutorial and adapt it for your own projects.<\/p>\n<p>Remember that this is just a secure base that you should work from. Consider changing or implementing your own validation, and implement your own features.<\/p>\n<p>If you would like more of this tutorial series, feel free to drop a comment and suggest to us what we could create next.<\/p>\n<p>Enjoy coding!<\/p>\n<div data-counters='false' data-style='square' data-size='small' data-url='https:\/\/hostscripter.com\/?p=1354' data-title='Part 6: 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=1354' data-title='Part 6: 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>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 [&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-lQ","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":1349,"url":"https:\/\/hostscripter.com\/?p=1349","url_meta":{"origin":1354,"position":0},"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":1343,"url":"https:\/\/hostscripter.com\/?p=1343","url_meta":{"origin":1354,"position":1},"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":1339,"url":"https:\/\/hostscripter.com\/?p=1339","url_meta":{"origin":1354,"position":2},"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":[]},{"id":1333,"url":"https:\/\/hostscripter.com\/?p=1333","url_meta":{"origin":1354,"position":3},"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":1335,"url":"https:\/\/hostscripter.com\/?p=1335","url_meta":{"origin":1354,"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":1347,"url":"https:\/\/hostscripter.com\/?p=1347","url_meta":{"origin":1354,"position":5},"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":[]}],"_links":{"self":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1354"}],"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=1354"}],"version-history":[{"count":1,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1354\/revisions"}],"predecessor-version":[{"id":1355,"href":"https:\/\/hostscripter.com\/index.php?rest_route=\/wp\/v2\/posts\/1354\/revisions\/1355"}],"wp:attachment":[{"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostscripter.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}