PHP Code:
<?php
class Login{
private $Table;
private $Structure;
function __construct($Table="", $Structure=""){
$this->Table = ($Table) ? $Table : "accounts";
$this->Structure = ($Structure) ? $Structure : Array("name", "password", "salt");
}
function __destruct(){
unset($this->Table);
unset($this->Structure);
unset($this);
}
function Login($Username, $Password){
global $MySQL;
$Username = $MySQL->Escape($Username);
$Password = $MySQL->Escape($Password);
$MySQL->Query("SELECT `{$this->Structure['0']}`, `{$this->Structure['1']}`, `{$this->Structure['2']}` FROM `{$this->Table}` WHERE `{$this->Structure['0']}` = '{$Username}';");
if($Row = $MySQL->Fetch_Array()){
if((sha1($Password . $Row[$this->Structure['2']])) == $Row[$this->Structure['1']]){
return true;
}
}
return false;
}
}
?>
Password stored in database must be hashed with SHA-1.
It is flexible so it uses any table and any field names.
Results 1 to 1 of 1
Thread: [PHP] Flexi Login Class
- 16 Nov. 2009 05:56am #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 500.00
[PHP] Flexi Login Class