Home arrow MySQL arrow Creating a Login Script for a PHP/MySQL Blogging System

Creating a Login Script for a PHP/MySQL Blogging System

In this three-part tutorial we are going to be creating an open blogging system. We are also going to provide scripts that will make it possible to switch to a closed blogging system. This article, which is the first part, will cover the creation of the login scripts for a closed system.

  1. Creating a Login Script for a PHP/MySQL Blogging System
  2. Login.php
  3. Logout.php
  4. Password.php
By: Jacques Noah
Rating: starstarstarstarstar / 90
October 03, 2006

print this article



The file for the login script can be downloaded here.
  • An open blogging system is a system that allows anyone to contribute to a blog without having to register. In many cases, it also allows any user to start a new topic that will then have its own replies,  as opposed to just commenting on a topic that the blog owner started. This kind of blog is suitable for people who have just created a website and do not have a lot of web traffic.
  • A closed blogging system is one that requires registration and allows most users to contribute to a topic instead of creating their own. This kind of blog is suitable for people that have a lot of traffic on their websites.

In the first part of this article, we will create a login script for those of you who prefer a closed blogging system. You can skip this part if you wish and come back next week to check out the next part in this series, which will deal with creating a blog if you are not interested in a closed system. The login script will have a MYSQL table which it will reference to verify the existence of a user at login. It will also have various scripts that will help register a new user and retrieve forgotten passwords.

Login Script

The login script will have the following pages:

  • Login.php - Enables users to log in.
  • Logout.php - Enables logging out.
  • Register.php - Creates new users.
  • Password.php - Password recovery.
  • Messages.php - Handles error messages.

Let's create a table that will gather the following information about a user:

  • Username
  • Password>
  • Level
    •  Admin - This will be the moderator of the system
    •  Normal - Normal access rights
  •  Date_joined
  • IP Address - Enables us to identify and ban users.
  • Email - Used for password recovery.
  • Isbanned - Enable us to ban users

Here's the table:

  `id` int(5) NOT NULL auto_increment,
  `uname` varchar(98) NOT NULL default '',
  `pw` varchar(98) NOT NULL default '',
  `email` varchar(100) NOT NULL default '',
  `date_joined` datetime NOT NULL default '0000-00-00 00:00:00',
  `ip` varchar(20) NOT NULL default '',
  `level` varchar(10) NOT NULL default '',
  `isbanned` enum('yes','no') NOT NULL default 'no',
  PRIMARY KEY  (`id`)

As you can see from the table layout, the table gathers a lot of information about a user. The most significant item of them all is the "isbanned" field. This field is responsible for checking whether or not a user is banned. The "ip" field stores the IP address of the user, which will be used to reinforce the isbanned status of a user.

Simply copy and paste the code into your PHP admin and run the SQL.

>>> More MySQL Articles          >>> More By Jacques Noah

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Oracle Unveils MySQL 5.6
- MySQL Vulnerabilities Threaten Databases
- MySQL Cloud Options Expand with Google Cloud...
- MySQL 5.6 Prepped to Handle Demanding Web Use
- ScaleBase Service Virtualizes MySQL Databases
- Oracle Unveils MySQL Conversion Tools
- Akiban Opens Database Software for MySQL Use...
- Oracle Fixes MySQL Bug
- MySQL Databases Vulnerable to Password Hack
- MySQL: Overview of the ALTER TABLE Statement
- MySQL: How to Use the GRANT Statement
- MySQL: Creating, Listing, and Removing Datab...
- MySQL: Create, Show, and Describe Database T...
- MySQL Data and Table Types
- McAfee Releases Audit Plugin for MySQL Users

Developer Shed Affiliates


Dev Shed Tutorial Topics: