MySQL
  Home arrow MySQL arrow Creating a Login Script for a PHP/MySQL Blogging System
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MYSQL

Creating a Login Script for a PHP/MySQL Blogging System
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 67
    2006-10-03


    Table of Contents:
  • Creating a Login Script for a PHP/MySQL Blogging System
  • Login.php
  • Logout.php
  • Password.php

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Creating a Login Script for a PHP/MySQL Blogging System
    ( Page 1 of 4 )

    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.
    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:

    CREATE TABLE `user` (
      `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`)
    ) TYPE=MyISAM AUTO_INCREMENT=11 ;

    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
     

       

    MYSQL ARTICLES

    - MySQL Security Tips
    - Designing a MySQL Database: Tips and Techniq...
    - The Three Most Important MySQL Queries
    - Null and Empty Strings
    - MySQL Server Tuning Tips and Tricks
    - MySQL Query Optimizations and Schema Design
    - MySQL Benchmarking Tools and Utilities
    - MySQL Benchmarking Concepts and Strategies
    - Take Some Load off MySQL with MemCached
    - MySQL Table Prefix Changer Tool in PHP
    - Using the SIGNAL Statement for Error Handling
    - Error Handling Examples
    - Error Handling
    - Completing a Search Engine with MySQL and PH...
    - Paginating Result Sets for a Search Engine B...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT