In order for an online store to keep track of what's in whose shopping trolley, the system needs to know which user is making specific requests. After users log in, they would get lost amongst all the other users if you didn't keep track of their session. By assigning a unique value to this user, the system can know who it is without having them log in on every page
Programming a php login script can be a real pain. It has to be well coded, unique and, most of all, secure. We will pass all the mentioned aspects of a php login system in this tutorial by actually building one. Today I'm going to teach you how to write a good login script with user levels (admin, members, managers etc.), with forgot password included, user activation upon registering and just about everything that is supposed to be included in a good login system. Just like we did on the search engine tutorial some while ago, we are going to code our project with multiple examples, upgrades of code and also by comparing a bad usage with a good one.
One cool thing about php is that you can fairly easily validate users before displaying content on a page by page basis. Let's say you don't want to restrict the entire directory using htaccess, this is a neat alternative. Let's create a login system using PHP and mySQL. First we need to create the table that holds our user data. We're going to have 3 fields, logged, which will keep track of the last time a person logged in to the page, user and pass which will be the username and password respectively. Using Telnet you can simply cut and paste this into your mySQL monitor. If you need help with how to log into the mySQL monitor then see the diary entry on connecting to mySQL.
Joining mailing list will entitle you
to receive occasional emails informing you of news and
updates to the site and any special offers that may be
of interest to you.