{"id":42423,"date":"2018-12-19T03:01:18","date_gmt":"2018-12-18T17:01:18","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=42423"},"modified":"2018-12-19T05:34:44","modified_gmt":"2018-12-18T19:34:44","slug":"registration-and-login-via-php-mcrypt-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/registration-and-login-via-php-mcrypt-primer-tutorial\/","title":{"rendered":"Registration and Login via PHP Mcrypt Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_login.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Registration and Login via PHP Mcrypt Primer Tutorial\" src=\"https:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_login.jpg\" title=\"Registration and Login via PHP Mcrypt Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Registration and Login via PHP Mcrypt Primer Tutorial<\/p><\/div>\n<p>We&#8217;re starting down the road of PHP <a target=_blank title='PHP mcrypt information, thanks' href='http:\/\/php.net\/manual\/en\/book.mcrypt.php'>mcrypt encryption and decryption methods<\/a> for a Membership Website, today establishing three webpages (that might be all you need to know &#8230; we&#8217;ll see) &#8230;<\/p>\n<ul>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_login.php_GETME\" title=\"mcrypt_login.php\">mcrypt_login.php<\/a> webpage handles &#8220;Register&#8221; and &#8220;Login&#8221; (button functionalities) &#8230; and that, if successful will navigate the user to &#8230;<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_first_nonlogin.php_GETME\" title=\"mcrypt_first_nonlogin.php\">mcrypt_first_nonlogin.php<\/a> webpage can be your template &#8230;<br \/>\n<code><br \/>\n&lt;?php<br \/>\n\/\/ mcrypt_first_nonlogin.php<br \/>\n\/\/ RJM Programming<br \/>\n\/\/ December, 2018<br \/>\n\/\/ Thanks to http:\/\/php.net\/manual\/en\/function.mdecrypt-generic.php<br \/>\n  session_start();<br \/>\n  if ($_SESSION['username']) {<br \/>\n      echo \"&lt;!doctype html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Registration and Login via PHP Mcrypt - RJM Programming - December, 2018&lt;\/title&gt;&lt;\/head&gt;&lt;body&gt;&lt;p&gt;Here at first non-login page.&lt;\/p&gt;&lt;br&gt;&lt;br&gt;&lt;input onclick=\\\" location.href='.\/mcrypt_logout.php'; \\\" type=button style=background-color:red; value=Logout&gt;&lt;\/input&gt;&lt;\/body&gt;&lt;\/html&gt;\";<br \/>\n  } else {<br \/>\n      echo \"&lt;!doctype html&gt;&lt;html&gt;&lt;head&gt;&lt;title&gt;Registration and Login via PHP Mcrypt - RJM Programming - December, 2018&lt;\/title&gt;&lt;\/head&gt;&lt;body onload=\\\" location.href='.\/mcrypt_login.php?redirectto=' + encodeURIComponent(document.URL); \\\"&gt;&lt;\/body&gt;&lt;\/html&gt;\";<br \/>\n  }<br \/>\n?&gt;<br \/>\n<\/code><br \/>\n &#8230; for any non-login page, that offers a &#8220;Logout&#8221; button &#8230; that calls &#8230;<\/li>\n<li><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_logout.php_GETME\" title=\"mcrypt_logout.php\">mcrypt_logout.php<\/a> webpage to clear the $_SESSION[] of the successful Login session, ready for another, as the user requires<\/li>\n<\/ul>\n<p>Don&#8217;t we need to mention a database or cookies or localStorage here?  Well, not really, because we self-contain the login data into the inaccessible (to the outside world) PHP code itself, getting the PHP to update itself on a successful click of the &#8220;Register&#8221; button.  That PHP updating of itself uses &#8230;<\/p>\n<ul>\n<li><a target=_blank href=\"http:\/\/php.net\/manual\/en\/function.mcrypt-generic.php\" title=\"mcrypt_generic\">mcrypt_generic<\/a><\/li>\n<li><a target=_blank href=\"http:\/\/php.net\/manual\/en\/function.mdecrypt-generic.php\" title=\"mdecrypt_generic\">mdecrypt_generic<\/a><\/li>\n<\/ul>\n<p> &#8230; in amongst its avoidance of showing any real username or password anywhere, even if that &#8220;anywhere&#8221; place is inaccessible to the world anyway.  In these terms why don&#8217;t you try out <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_login.php_GETME\" title=\"mcrypt_login.php\">mcrypt_login.php<\/a>&#8216;s <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_login.php\" title=\"Click picture\">live run<\/a> to see what we mean (and if you do not feel like adding your own Registration you can use &#8220;Robert&#8221; and &#8220;testing_times&#8221; as a Login here).  As you examine the PHP codesets above, see how <a target=_blank title='PHP $_SESSION use' href='http:\/\/php.net\/manual\/en\/reserved.variables.session.php'>$_SESSION[&#8216;username&#8217;]<\/a> usage stops a user coming into <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_first_nonlogin.php_GETME\" title=\"mcrypt_first_nonlogin.php\">mcrypt_first_nonlogin.php<\/a> (and <a target=_blank href=\"https:\/\/www.rjmprogramming.com.au\/PHP\/mcrypt_first_nonlogin.php\" title=\"mcrypt_first_nonlogin.php\">try that for yourself here<\/a> if you like) without logging in.<\/p>\n<p>Then, perhaps, compare and contrast to previous (PHP) Registration thinking in <a title='Registration via Captcha Primer Tutorial' href='#rcpt'>Registration via Captcha Primer Tutorial<\/a> below.<\/p>\n<hr>\n<p id='rcpt'>Previous relevant <a target=_blank title='Registration via Captcha Primer Tutorial' href='\/\/www.rjmprogramming.com.au\/ITblog\/registration-via-captcha-primer-tutorial\/'>Registration via Captcha Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_captcha.php?admin=y\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Registration via Captcha Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/registration_viacaptcha.jpg\" title=\"Registration via Captcha Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Registration via Captcha Primer Tutorial<\/p><\/div>\n<p>We, pretty obviously, spoke too soon, yesterday, that that was it, or words to that effect, with this topic, and that is no wonder, as it covers a lot of territory.<\/p>\n<p>Up to now, we&#8217;ve restricted its scope, hugely, by saying there are only &#8220;admin&#8221; users and &#8220;guest&#8221; users involved with &#8230; <\/p>\n<blockquote><p>\n&#8230; the idea that the &#8220;Things That We Have in Common&#8221; far outweigh the things that divide us, and present some ideas here &#8230;\n<\/p><\/blockquote>\n<p> &#8230; because with a real blog or CMS or social media scenario there are real users with real needs that it is preferable to cater for with real software &#8230; so even though we are still just theoretical here, short of a full blown website, let&#8217;s get onto the topic of &#8220;registration&#8221;.  &#8220;Registration&#8221; is the creation of a new user registered with your web application, that you see a lot of, all over the web.<\/p>\n<p>Ideally you register a real human user, though we would really enjoy any Martian to register (for free, plus a prize of one free Earth Bar) &#8230; but we digress.  So today we channel the tutorial of yesterday to go over the top with <a target=_blank title='CAPTCHA information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/CAPTCHA'>CAPTCHA<\/a> again.  In fairness to CAPTCHA, though, the best place to use it is during login and\/or registration procedures.<\/p>\n<p>What are the changes that phpMyAdmin helps us with regarding the database &#8230; well, with regard to the `rusers` MySql table we have we append to the pre-existing &#8230;<\/p>\n<ul>\n<li>username<\/li>\n<li>password &#8230; columns, the new &#8230;<\/li>\n<li>email<\/li>\n<li>usertype<\/li>\n<\/ul>\n<p> &#8230; because, respectively, `email` is great to use both for what it is, and as a database uniqueness constraint method, and `usertype` is where we define our new list of user types, namely &#8230;<\/p>\n<ul>\n<li>admin &#8230; the only real type up to now &#8230; but, as of today, specifiable (in addition to &#8220;guest&#8221; users) are &#8230;<\/li>\n<li>registered<\/li>\n<li>subscriber<\/li>\n<\/ul>\n<p> &#8230; and ask the user what they want to be out of those last two.  We don&#8217;t do so much different here, but we just want to show you today an approach to organize yourself regarding compartmentalizing this &#8220;real world&#8221; real user thinking that is a bit like &#8220;shelling peas&#8221; once all this is set up &#8230; and modularizable and job-assignment-to-a-worker-friendly because you get to a one PHP set of code per one user type scenario, once you&#8217;re finished.<\/p>\n<p>As you might imagine the biggest changes today are to our login.php rather than to member.php and moderator_captcha.php (the main changers yesterday) &#8230;<\/p>\n<p>Here is the login PHP code for all registered users you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php--GETME\">login.php<\/a> with its admin user useful <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php\">live run<\/a>, changed a lot from previously to handle registration and more varied user types <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php--GETME\">this way<\/a>.<\/p>\n<p>Here is the member PHP code that follows the login(.php) page you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/member.php---GETME\">member.php<\/a> changed a little (but very importantly) from yesterday&#8217;s work <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/member.php---GETME\">this way<\/a> to restrict its usage to &#8216;admin&#8217; user types.<\/p>\n<p>Here is new template like PHP code (nirvana for <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a>) for registered users you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/registered.php_GETME\">registered.php<\/a><\/p>\n<p>Here is new template like PHP code (nirvana for <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a>) for subscriber users you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/subscriber.php_GETME\">subscriber.php<\/a><\/p>\n<p>We found two great book sources researching these blog posts, particularly regarding the subject of &#8220;membership&#8221;.  They are &#8230;<\/p>\n<ul>\n<li><i>PHP and MySql Web Development<\/i> by Luke Welling, Laura Thomson<\/li>\n<li><i>Professional PHP Programming<\/i> by Jesus Castagnetto, Haeish Rawat, Sascha Schumann, Chris Scollo, Deepak Veliath &#8230; chapter 20<\/li>\n<\/ul>\n<p>Finally, here is a <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_captcha.php?admin=y\">live run<\/a> link that interfaces this to the moderation ideas of previous days.<\/p>\n<hr>\n<p id='mbcpt'>Previous relevant <a target=_blank title='Moderation by Captcha Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/moderation-by-captcha-primer-tutorial\/'>Moderation by Captcha Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_captcha.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Moderation by Captcha Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_viacaptcha.jpg\" title=\"Moderation by Captcha Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Moderation by Captcha Primer Tutorial<\/p><\/div>\n<p>In our <a target=_blank title='?' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/?s=onions+of+the+4th+dimension&#038;stype=Search'>&#8220;onions of the 4th dimension&#8221;<\/a> world we have an onion layer of thought today regarding &#8220;moderation&#8221;.<\/p>\n<p>Let me just quietly ask?  <font size=1>Are you a robot?<\/font>  Mr Turing posed this very fundamental question some time back.  <font size=1>But the fact is, a lot of visitors to just about everybody&#8217;s website are robots (shock! &#8230; horror!), else how else would Search Engines get updated information, but to &#8220;crawl&#8221; your website (as I say this, forgot to say how blogs like <a target=_blank title='WordPress relationship with pingomatic' href='https:\/\/wordpress.org\/support\/topic\/how-does-wordpress-automatically-ping-pingomatic'>WordPress<\/a> <a target=_blank title='Ping information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Ping_%28networking_utility%29'>ping<\/a> <a target=_blank title='Search engine information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Web_search_engine'>Search Engines<\/a>), <strike>man<\/strike> person.<\/font><\/p>\n<p>And just to get in (really) early <font size=1>(with the way modern technology is shaping)<\/font> &#8230; &#8220;Not that there&#8217;s anything wrong with being a robot&#8221; (if only <a target=_blank title='Seinfeld' href='https:\/\/www.youtube.com\/watch?v=rGAyQAkXajg'>Seinfeld<\/a> had watched <a target=_blank title='Humans BBC television series' href='http:\/\/www.imdb.com\/title\/tt4122068\/'>Humans<\/a> &#8230; Jerry?! George?!).<\/p>\n<p>So let&#8217;s talk about <a target=_blank title='CAPTCHA information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/CAPTCHA'>CAPTCHA<\/a>, which we have not capitalized in the blog title, because we hate shouting too much here.  It is a way to try to verify the web application is dealing with a real human being, as we intimated above.  As such, you may want to consider it a replacement for &#8220;moderation&#8221;, but this is not advisable, because, alas, not all the nasty stuff on the net can be attributed to robots &#8230; far from it.  But it is a good idea up to a point.  My personal objection to its use revolves around the disturbance of usage for some disabled users, though am sure there are really sophisticated CAPTCHA plugins for all the scenarios out there.<\/p>\n<p>Today&#8217;s work places a CAPTCHA layer on top of all four previously talked about modes of &#8220;moderation&#8221;, as per &#8230;<\/p>\n<ul>\n<li>no moderation &#8230; even this needs a server side language, in our eyes, because you will be changing a server side webpage for all users<\/li>\n<li>email (or sms or voicemail or any direct communication method) moderation &#8230; ask for an admin user of the website to change things after having emailed them &#8230; this is the one we showed three days back &#8230; and please feel free to try your own entries<\/li>\n<li>moderate via a (web server) database with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221; &#8230; this is the one we showed yesterday &#8230; and, yet again, please feel free to try your own entries<\/li>\n<li>moderate via a system of (web server) files with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221; &#8230; this is the one we showed two days back &#8230; and, again, please feel free to try your own entries<\/li>\n<li>only moderate to either of the four above after having gone through a <a target=_blank title='CAPTCHA information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/CAPTCHA'>CAPTCHA<\/a> test that the user is not a robot &#8230; this is the one we show today<\/li>\n<\/ul>\n<p>To get the PHP CAPTCHA functionality going we thank this very <a target=_blank title='Useful link' href='http:\/\/www.the-art-of-web.com\/php\/captcha\/'>useful link<\/a> from &#8220;The Art of Web&#8221; website.  Its precise and clever advice creates the imagery required to present a CAPTCHA image to the user that contains five digits for the user to enter to verify to the web application that they are human.  The web application CAPTCHA logic is applied to all the method=POST forms used (and a new form was encased around the &#8220;private moderation&#8221; (ie. no moderation) case) via the HTML form&#8217;s &#8230;<\/p>\n<p><code> ... <a target=_blank title='Javascript onsubmit event information from w3schools' href='http:\/\/www.w3schools.com\/jsref\/event_onsubmit.asp'>onsubmit<\/a>=\"return checkForm(this);\" ...<\/code><\/p>\n<p> &#8230; validation method.<\/p>\n<p>So, for the last time, today, we pose the idea that the &#8220;Things That We Have in Common&#8221; far outweigh the things that divide us, and present some ideas here.  We offer, and encourage you to email us your ideas on the topic or use the file moderation method, and we&#8217;ll moderate them within 24 hours.  With today&#8217;s file moderation method you are given the opportunity to login and &#8220;moderate&#8221; your own work but as you will recall from yesterday with &#8230;<\/p>\n<p>CAPTCHA does not affect user roles going forward.  In all these scenarios we present, where we don&#8217;t ask anything of you (ie. no registration), except an email address, presumably, you can be thought of as a &#8230;<\/p>\n<blockquote>\n<ul>\n<li>&#8220;guest&#8221; user &#8230; though in strict terms the word &#8220;guest&#8221; usually implies that there is a user registration involved &#8230; which we do not do here today &#8230; but to read a bit about this you could read <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a> &#8230; as distinct from &#8230;<\/li>\n<li>the emailee of the &#8220;guest&#8221; user will be an &#8220;admin&#8221; user &#8230; one who can offer the means to moderate the uploaded data, and, as approved, write that data to a place where it will be picked up and included in the contents of the webpage(s) involved &#8230; hence the term &#8220;Content Management System&#8221;<\/li>\n<\/ul>\n<\/blockquote>\n<p> &#8230; you, as a &#8220;guest&#8221; user will not succeed with this &#8220;admin&#8221; user login to &#8220;moderate&#8221;, but the mechanism is there for real &#8220;admin&#8221; users, as is a &#8220;get&#8221; parameter method like our &#8220;?admin=y&#8221; idea, with most blogs and CMS websites.<\/p>\n<p>Here is the downloadable PHP code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_captcha.php---GETME\">moderation_captcha.php<\/a> with its <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_captcha.php\">live run<\/a> and changed from yesterday&#8217;s work <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php--GETME\">this way<\/a>.<\/p>\n<p>Here is the login PHP code for the admin section you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php-GETME\">login.php<\/a> with its admin user useful <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php\">live run<\/a>, unchanged from yesterday.<\/p>\n<p>Here is the PHP code login(.php) uses to connect to the MySql database you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/db_connect.php_GETME\">db_connect.php<\/a> unchanged from yesterday.<\/p>\n<p>Here is the member PHP code that follows the login(.php) page you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/member.php--GETME\">member.php<\/a> that handles, so far, the &#8220;business logic&#8221; for file moderation as of yesterday and the admin user follow up to reading the email and approving the email moderation, of two days back, as well as today&#8217;s extended MySql database functionality, is not needing to change from yesterday&#8217;s work regarding CAPTCHA.<\/p>\n<hr>\n<p id='mbmdpt'>Previous relevant <a target=_blank title='Moderation by MySql Database Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/moderation-by-mysql-database-primer-tutorial\/'>Moderation by MySql Database Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php?admin=y\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Moderation by MySql Database Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_viadb.jpg\" title=\"Moderation by MySql Database Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Moderation by MySql Database Primer Tutorial<\/p><\/div>\n<p>Today&#8217;s the day we tackle some database &#8220;moderation&#8221; ideas.  You will recall from yesterday&#8217;s <a target=_blank title='Moderation by Email Primer Tutorial' href='#mbfpt'>Moderation by File Primer Tutorial<\/a> as shown below, that &#8220;moderation&#8221; is associated with blogs and <a target=_blank title='CMS information by Wikipedia' href='https:\/\/en.wikipedia.org\/wiki\/Content_management_system'>Content Management Systems<\/a> and social media as a means by which uploaded content can be vetted, or not, during a &#8220;moderation phase&#8221; for a posting of some sort.<\/p>\n<p>This can involve, in our eyes, quite a few options, none of which would not involve a server-side solution of some sort &#8230;<\/p>\n<ul>\n<li>no moderation &#8230; even this needs a server side language, in our eyes, because you will be changing a server side webpage for all users<\/li>\n<li>email (or sms or voicemail or any direct communication method) moderation &#8230; ask for an admin user of the website to change things after having emailed them &#8230; this is the one we showed two days back &#8230; and please feel free to try your own entries<\/li>\n<li>moderate via a (web server) database with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221; &#8230; this is the one we show today &#8230; and, yet again, please feel free to try your own entries<\/li>\n<li>moderate via a system of (web server) files with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221; &#8230; this is the one we showed yesterday &#8230; and, again, please feel free to try your own entries<\/li>\n<li>only moderate to either of the four above after having gone through a <a target=_blank title='CAPTCHA information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/CAPTCHA'>CAPTCHA<\/a> test that the user is not a robot<\/li>\n<\/ul>\n<p>So today we are still here posing the idea that the &#8220;Things That We Have in Common&#8221; far outweigh the things that divide us, and present some ideas here.  We offer, and encourage you to email us your ideas on the topic or use the file moderation method, and we&#8217;ll moderate them within 24 hours.  With today&#8217;s file moderation method you are given the opportunity to login and &#8220;moderate&#8221; your own work but as you will recall from yesterday with &#8230;<\/p>\n<p>The major lesson today, for us, is to show you the brilliance of phpMyAdmin as the administrator back-end to a MySql database.  Some of the great features of phpMyAdmin we used to get to this point are &#8230;<\/p>\n<ul>\n<li>phpMyAdmin&#8217;s great ability to export (to SQL, most usefully) the structure, in terms of &#8220;CREATE TABLE&#8221; type SQL and\/or data of existant database tables as a useful way to help design your own new database tables<\/li>\n<li>phpMyAdmin&#8217;s ease of use of the usual <a target=_blank title='Data Manipulation Language information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Data_manipulation_language'>DML<\/a> SQL functionality<\/li>\n<li>phpMyAdmin&#8217;s ease of use of the usual <a target=_blank title='Data Definition Language information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/Data_definition_language'>DDL<\/a> SQL functionality for the creation of users and the granting or denial of user priviledges, and drop and truncate functionalities<\/li>\n<\/ul>\n<p>We still have the two basic web user roles going today.  In this scenario, where we don&#8217;t ask anything of you (ie. no registration), except an email address, presumably, you can be thought of as a &#8230;<\/p>\n<blockquote>\n<ul>\n<li>&#8220;guest&#8221; user &#8230; though in strict terms the word &#8220;guest&#8221; usually implies that there is a user registration involved &#8230; which we do not do here today &#8230; but to read a bit about this you could read <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a> &#8230; as distinct from &#8230;<\/li>\n<li>the emailee of the &#8220;guest&#8221; user will be an &#8220;admin&#8221; user &#8230; one who can offer the means to moderate the uploaded data, and, as approved, write that data to a place where it will be picked up and included in the contents of the webpage(s) involved &#8230; hence the term &#8220;Content Management System&#8221;<\/li>\n<\/ul>\n<\/blockquote>\n<p> &#8230; you, as a &#8220;guest&#8221; user will not succeed with this &#8220;admin&#8221; user login to &#8220;moderate&#8221;, but the mechanism is there for real &#8220;admin&#8221; users, as is a &#8220;get&#8221; parameter method like our &#8220;?admin=y&#8221; idea, with most blogs and CMS websites.<\/p>\n<p>You will recall yesterday that ideas from <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a> came into play with the use of web server files and today its functionality is even more important with some MySql database work to follow up on phpMyAdmin database setup preparation.  It screens &#8220;admin&#8221; users from the rest, ensuring you can write your fully functional database PHP free in the knowledge that the user is logged in as an &#8220;admin&#8221; user.<\/p>\n<p>Here is the downloadable PHP code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php--GETME\">moderation.php<\/a> with its <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php\">live run<\/a> and changed from yesterday&#8217;s work <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php--GETME\">this way<\/a>.<\/p>\n<p>Here is the login PHP code for the admin section you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php-GETME\">login.php<\/a> with its admin user useful <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php\">live run<\/a>, unchanged from yesterday.<\/p>\n<p>Here is the PHP code login(.php) uses to connect to the MySql database you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/db_connect.php_GETME\">db_connect.php<\/a> unchanged from yesterday.<\/p>\n<p>Here is the member PHP code that follows the login(.php) page you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/member.php--GETME\">member.php<\/a> that handles, so far, the &#8220;business logic&#8221; for file moderation as of yesterday and the admin user follow up to reading the email and approving the email moderation, of two days back, as well as today&#8217;s extended MySql database functionality, is changed from yesterday&#8217;s work <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/member.php--GETME\">this way<\/a>.<\/p>\n<hr>\n<p id='mbfpt'>Previous relevant <a target=_blank title='Moderation by File Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/moderation-by-file-primer-tutorial\/'>Moderation by File Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php?admin=y\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Moderation by File Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation_viafile.jpg\" title=\"Moderation by File Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Moderation by File Primer Tutorial<\/p><\/div>\n<p>We continue on with &#8220;moderation&#8221; ideas today, as with WordPress 4.1.1&#8217;s <a target=_blank title='Moderation by File Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/moderation-by-file-primer-tutorial\/'>Moderation by File Primer Tutorial<\/a>.  You will recall from yesterday&#8217;s <a target=_blank title='Moderation by Email Primer Tutorial' href='#mbept'>Moderation by Email Primer Tutorial<\/a> as shown below, that &#8220;moderation&#8221; is associated with blogs and <a target=_blank title='CMS information by Wikipedia' href='https:\/\/en.wikipedia.org\/wiki\/Content_management_system'>Content Management Systems<\/a> and social media as a means by which uploaded content can be vetted, or not, during a &#8220;moderation phase&#8221; for a posting of some sort.<\/p>\n<p>This can involve, in our eyes, quite a few options, none of which would not involve a server-side solution of some sort &#8230;<\/p>\n<ul>\n<li>no moderation &#8230; even this needs a server side language, in our eyes, because you will be changing a server side webpage for all users<\/li>\n<li>email (or sms or voicemail or any direct communication method) moderation &#8230; ask for an admin user of the website to change things after having emailed them &#8230; this is the one we showed yesterday &#8230; and please feel free to try your own entries<\/li>\n<li>moderate via a (web server) database with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221;<\/li>\n<li>moderate via a system of (web server) files with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221; &#8230; this is the one we show today &#8230; and, again, please feel free to try your own entries<\/li>\n<li>only moderate to either of the four above after having gone through a <a target=_blank title='CAPTCHA information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/CAPTCHA'>CAPTCHA<\/a> test that the user is not a robot<\/li>\n<\/ul>\n<p>So today we continue to pose the idea that the &#8220;Things That We Have in Common&#8221; far outweigh the things that divide us, and present some ideas here.  We offer, and encourage you to email us your ideas on the topic or use the file moderation method, and we&#8217;ll moderate them within 24 hours.  With today&#8217;s file moderation method you are given the opportunity to login and &#8220;moderate&#8221; your own work but as you will recall from yesterday with &#8230;<\/p>\n<p>This brings up the topic of web user roles.  In this scenario, where we don&#8217;t ask anything of you, except an email address, presumably, you can be thought of as a &#8230;<\/p>\n<blockquote>\n<ul>\n<li>&#8220;guest&#8221; user &#8230; though in strict terms the word &#8220;guest&#8221; usually implies that there is a user registration involved &#8230; which we do not do here today &#8230; but to read a bit about this you could read <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a> &#8230; as distinct from &#8230;<\/li>\n<li>the emailee of the &#8220;guest&#8221; user will be an &#8220;admin&#8221; user &#8230; one who can offer the means to moderate the uploaded data, and, as approved, write that data to a place where it will be picked up and included in the contents of the webpage(s) involved &#8230; hence the term &#8220;Content Management System&#8221;<\/li>\n<\/ul>\n<\/blockquote>\n<p> &#8230; you, as a &#8220;guest&#8221; user will not succeed with this &#8220;admin&#8221; user login to &#8220;moderate&#8221;, but the mechanism is there for real &#8220;admin&#8221; users, as is a &#8220;get&#8221; parameter method like our &#8220;?admin=y&#8221; idea, with most blogs and CMS websites.<\/p>\n<p>The reason we didn&#8217;t need these <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a> ideas yesterday was that no web server files had to be written at that stage, but today they do, and we can&#8217;t let any &#8220;guest&#8221; user do it, so we find that MySql database work via the wonderful and enormously stupendous phpMyAdmin comes into play, and we&#8217;ll talk more about this tomorrow, when databases are used for all aspects of our final &#8220;moderation&#8221; via database discussion.<\/p>\n<p>Here is the downloadable PHP code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php-GETME\">moderation.php<\/a> with its <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php\">live run<\/a> and changed from yesterday&#8217;s work <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Geographicals\/diff.php?one=http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php-GETME\">this way<\/a>.<\/p>\n<p>Here is the login PHP code for the admin section you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php-GETME\">login.php<\/a> with its admin user useful <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/login.php\">live run<\/a>.<\/p>\n<p>Here is the PHP code login(.php) uses to connect to the MySql database you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/db_connect.php_GETME\">db_connect.php<\/a><\/p>\n<p>Here is the member PHP code that follows the login(.php) page you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/member.php-GETME\">member.php<\/a> that handles, so far, the &#8220;business logic&#8221; for file moderation and the admin user follow up to reading the email and approving the email moderation, of yesterday.<\/p>\n<hr>\n<p id='mbept'>Previous relevant <a target=_blank title='Moderation by Email Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/moderation-by-email-primer-tutorial\/'>Moderation by Email Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php\"><img decoding=\"async\" style=\"float:left;border: 15px solid pink;\" alt=\"Moderation by Email Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/PHP\/moderation.jpg\" title=\"Moderation by Email Primer Tutorial\"  \/><\/a><p class=\"wp-caption-text\">Moderation by Email Primer Tutorial<\/p><\/div>\n<p>The term &#8220;moderation&#8221; is associated with blogs and <a target=_blank title='CMS information by Wikipedia' href='https:\/\/en.wikipedia.org\/wiki\/Content_management_system'>Content Management Systems<\/a> and social media as a means by which uploaded content can be vetted, or not, during a &#8220;moderation phase&#8221; for a posting of some sort.<\/p>\n<p>This can involve, in our eyes, quite a few options, none of which would not involve a server-side solution of some sort.  We&#8217;ll think on this further (maybe Ajax?!), but some of the ideas for moderation would be &#8230;<\/p>\n<ul>\n<li>no moderation &#8230; even this needs a server side language, in our eyes, because you will be changing a server side webpage for all users<\/li>\n<li>email (or sms or voicemail or any direct communication method) moderation &#8230; ask for an admin user of the website to change things after having emailed them &#8230; this is the one we show today &#8230; and please feel free to try your own entries<\/li>\n<li>moderate via a (web server) database with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221;<\/li>\n<li>moderate via a system of (web server) files with posting statuses such as &#8220;Awaiting Moderation&#8221;, &#8220;Published&#8221;, &#8220;To Be Deleted&#8221;<\/li>\n<li>only moderate to either of the four above after having gone through a <a target=_blank title='CAPTCHA information from Wikipedia ... thanks' href='https:\/\/en.wikipedia.org\/wiki\/CAPTCHA'>CAPTCHA<\/a> test that the user is not a robot<\/li>\n<\/ul>\n<p>So today we pose the idea that the &#8220;Things That We Have in Common&#8221; far outweigh the things that divide us, and present some ideas here.  We offer, and encourage you to email us your ideas on the topic, and we&#8217;ll moderate them within 24 hours.  The mechanism, today, is via you, the user, sending us here, at RJM Programming, an email.<\/p>\n<p>This brings up the topic of web user roles.  In this scenario, where we don&#8217;t ask anything of you, except an email address, presumably, you can be thought of as a &#8230;<\/p>\n<ul>\n<li>&#8220;guest&#8221; user &#8230; though in strict terms the word &#8220;guest&#8221; usually implies that there is a user registration involved &#8230; which we do not do here today &#8230; but to read a bit about this you could read <a target=_blank title='PHP Membership Website Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/php-membership-website-primer-tutorial\/'>PHP Membership Website Primer Tutorial<\/a> &#8230; as distinct from &#8230;<\/li>\n<li>the emailee of the &#8220;guest&#8221; user will be an &#8220;admin&#8221; user &#8230; one who can offer the means to moderate the uploaded data, and, as approved, write that data to a place where it will be picked up and included in the contents of the webpage(s) involved &#8230; hence the term &#8220;Content Management System&#8221;<\/li>\n<\/ul>\n<p> &#8230; and so, in the scenario of &#8220;no moderation&#8221; &#8220;guest&#8221; users circumvent the moderation part of the &#8220;admin&#8221; user role and, in some automated (programming) way, with a language like PHP and a database like MySql, be able to get their uploaded content straight onto the webpage(s) of interest.  So, sometimes you see &#8220;no moderation&#8221; but a CAPTCHA (robot) check, as the scenario of use.<\/p>\n<p>Of interest, too, is the nature of the uploaded data.  Is it &#8220;just text&#8221; or &#8220;can it contain images&#8221; or &#8220;can it contain videos&#8221; etcetera.  Today, we are just allowing text.<\/p>\n<p>Here is the downloadable PHP code you could call <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php_GETME\">moderation.php<\/a> with its <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/PHP\/Moderation\/moderation.php\">live run<\/a>.<\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18494' onclick='var dv=document.getElementById(\"d18494\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/cms\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18494' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18511' onclick='var dv=document.getElementById(\"d18511\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/membership\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18511' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18532' onclick='var dv=document.getElementById(\"d18532\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/phpmyadmin\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18532' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18543' onclick='var dv=document.getElementById(\"d18543\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/captcha\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18543' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d18558' onclick='var dv=document.getElementById(\"d18558\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/registration\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d18558' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d42423' onclick='var dv=document.getElementById(\"d42423\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/login\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d42423' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>We&#8217;re starting down the road of PHP mcrypt encryption and decryption methods for a Membership Website, today establishing three webpages (that might be all you need to know &#8230; we&#8217;ll see) &#8230; mcrypt_login.php webpage handles &#8220;Register&#8221; and &#8220;Login&#8221; (button functionalities) &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/registration-and-login-via-php-mcrypt-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,14,37],"tags":[2767,2769,386,1565,2768,765,932,997,1041,1114,1319],"class_list":["post-42423","post","type-post","status-publish","format-standard","hentry","category-elearning","category-event-driven-programming","category-tutorials","tag-_session","tag-decryption","tag-encryption","tag-login","tag-mcrypt","tag-membership","tag-php","tag-programming","tag-registration","tag-security","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/42423"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=42423"}],"version-history":[{"count":10,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/42423\/revisions"}],"predecessor-version":[{"id":42433,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/42423\/revisions\/42433"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=42423"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=42423"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=42423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}