MySQL
  Home arrow MySQL arrow Creating a Login Script for a PHP/MySQ...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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: 4 stars4 stars4 stars4 stars4 stars / 52
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    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


       · I think there are many flaws to this approach. There is no validation to really keep...
       · This is horrible php coding practice! Data access layer is mixed in with...
       · I just got done reading through the article and looking at the code samples. To be...
       · > I just got done reading through the article and looking at the code samples. > To...
       · I have to agree, I am just starting out on php/mysql and looking to create a user...
       · After reading this article i simply took the code, modified it and used it in one of...
       · I thought this article and the others were quite educational. I am aware of the...
       · Your are 100% correct, but it seems like your are a Pro, u know more about it, the...
       · I keep getting a parse error on line 10 of this code and need some help....
       · If you're gonna user double quotes inside a string, you need to escape them. Either...
       · The above response is correct. The other quotes in your string are causing your...
     

       

    MYSQL ARTICLES

    - 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...
    - Building a Search Engine with MySQL and PHP 5
    - Using Boolean Operators for Full Text and Bo...
    - PHP, MySQL and the PEAR Database
    - Working with PHP and MySQL
    - Getting PHP to Talk to MySQL
    - Creating an RSS Reader: the Reader
    - MySQL Security Overview
    - Creating the Admin Script for a PHP/MySQL Bl...
    - Creating the Blog Script for a PHP/MySQL Blo...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway