PHP Login Script

By • Jan 6th, 2009 • Category: Projects

Several sites I am working on required some kind of authentication using PHP, but since the sites were entirely custom coded – and needed to be to serve their purpose – I was unable and unwilling to use a CMS just to have user registration and logins.

My solution was to come up with a PHP class that can add secure authentication to any site it’s dropped into. A few lines of configuration are required, but after that it’s fast, secure, and ready to go.

The script uses uses PDO and SQLite3 to quickly read and write user information to an SQLite database, rather than requiring MySQL to be setup, but most likely I will add MySQL support when the need arises.

Requirements

  • PHP5+ w/ PDO & PDO-SQLite enabled
  • Apache w/ mod_rewrite enabled

Features

  • Authentication using PHP and SQLite
  • Expiring nonces to deter spam and session hijacking
  • Salted passwords and sessions
  • Secured against SQL Injection
  • Built in change password, e-mail address, & password recovery
  • Account activation & user registration notification
  • Extendable using plugins
  • Valid XHTML 1.0 Strict

Demo

Download

Source

Support

Check out my post on Post Topic for more information.  The script is released under the GPL.

Tagged as: , , , , , ,


Email this author | All posts by

4 Responses »

  1. Congratulations on your 2 yr old child! I have a little boy 3 1/2.

    You know, there are a billion websites that use a PHP/MySQL login system that includes registration, with a confirmation email containing an account activation link, remember me and forgot password functions. I have spent at least 100 hours looking for a free script that will give that system, and there isn’t one on the internet. Seems impossible to believe, but I can find flat-file basic systems, and basic PHP/MySQL setups, but anything more than basic username/password registration seems to be unavailable. Soooo many I have tried that didn’t work, spent hours upon hours trying to make them work, give up, search the web more, scrutinize website upon website and keep trying new scripts–none of which work.
    Including yours.
    I am using PHP 5.2.8, MySQL 5.1, Apache 2.2 on Windows 7.
    What seems to be the problem… ?
    With all your files moved to htdocs, when I open 127.0.0.1 I get this:

    Notice: Undefined index: thumbprint in C:Program Files (x86)Apache Software FoundationApache2.2htdocsfunctions.php on line 211

    You are not logged in. Log in now or Sign up.

    When I click on either the Login or Sign up link, the page goes to 127.0.0.1/signup—not signup.php, and I get HTTP 404 error. If I append it to 127.0.0.1/signup.php I get the Sign up Page–plus:
    Notice: Undefined index: message in C:Program Files (x86)Apache Software FoundationApache2.2htdocsfunctions.php on line 35.
    All ditto if I click on the Login in now link—> 127.0.0.1/login–not login.php, and on appending it I get the Login Page with the same notice, ie,
    Notice: Undefined index: message in C:Program Files (x86)Apache Software FoundationApache2.2htdocsfunctions.php on line 35.
    And your script all in all doesn’t work.
    Would you happen to know where I can find a working script that I require? I really don’t have the time to sit down and learn PHP to the extent that I am competent to write a script of that comlexity–even if it isn’t really oh-so-complex as far as programming goes.
    This is all just for a fun website that will only be used for my friends and whatever ppl they in turn might send to my site, it is definitely non-commercial.
    Again, congrats on the baby!

  2. Hi, this is *really* nice, but the demo version uses mySQL ! Can you please show us the sqlite version ? Please Please Please Please Please ? ;)

  3. thank you,i finally got a script that i see can work with some modifications.can u believe there people who have the balls to sell scripts and not for small cash,they ask for $150dollars

  4. I no idea how to solve this problem.
    version mysql

    index.php
    Notice: Undefined index: thumbprint in /opt/lampp/htdocs/includes/functions.php on line 211

    login.php e signup.php
    Notice: Undefined index: message in /opt/lampp/htdocs/includes/functions.php on line 35

    thank you

    note: I will try the Sqlite version

Trackbacks

Leave a Reply