Quote of the day : "Philosophy is the talk on a cereal box" Emma Bunton

Next quote in 21.8 hours. [suggest a quote]

Login script

Important notice : this is an almost completely rewritten script, close to the one in use on our site. The former version ("revision #2") is a security holes heaven. You should absolutely switch to this version.
Archive contents :
- create_table.php : 
	run it once (after editing its parameters ! ;) ) to create the data table.
- login.php :
	the login script.
- mypage.php :
	an example of protected page. Note that you have to add session_start() at the
	very beginning of each protected page.
- GNUGPL.txt : 
	The GNU General Public License :)

Required : PHP and MySQL
Recommended : phpMyAdmin
Tested with : Apache/2.0.53 (Win32) - PHP/5.0.3 - MySQL 4.1.10a-nt
If you don't know how to install an Apache server on your Windows computer, see this tutorial :
	-> Installing an Apache server on Windows <http://www.patheticcockroach.com/mpam4/index.php?p=32>

How to get it work :
1. Enter your database informations in create_table.php and login.php
2. Run create_table.php to create the table
3. Add session_start(); and include("login.php"); in the page(s) where you want the user to be able to log in
4. Add session_start(); and the if (isset($_SESSION["uname"])) checks in all the pages you need to protect


/*************************************************************************
*                                                                        *
* This script can protect pages by asking for a login & password, read   *
* in the table that can be created with create_table.php                 *
*                                                                        *
* Copyright (C) 2004-2006 PatheticCockroach                              *
*                    http://www.patheticcockroach.com                    *
*                    Version 3.0                                         *
*                                                                        *
* This program is free software; you can redistribute it and/or modify   *
* it under the terms of the GNU General Public License as published by   *
* the Free Software Foundation; either version 2, or (at your option)    *
* any later version.                                                     *
*                                                                        *
* This program is distributed in the hope that it will be useful,        *
* but WITHOUT ANY WARRANTY; without even the implied warranty of         *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
* GNU General Public License for more details.                           *
*                                                                        *
* You should have received a copy of the GNU General Public License      *
* along with this program; if not, write to the Free Software            *
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              *
* You can also provide yourself with an online copy of the text:         *
* <http://www.gnu.org/copyleft/gpl.html>                                 *
* <http://www.gnu.org/copyleft/gpl.txt>                                  *
*                                                                        *
*************************************************************************/

!======> Change log <======!
2006-04-16 (3.0) :
	- SECURITY FIXES (sql injections)
	- added an IP security (session restricted to a single IP)
	- added a security against someone trying a lot of passwords
	(with default settings, you can try 3 passwords every 10 minutes)
	- the example page is now XHTML 1.1 compliant
Download

Screenshot

Login script screeshot
Comments :
No comments yet
You need to login (or create an account) in order to be able to post/edit/report comments.